Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion edb/edgeql/compiler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,24 @@ def compile_ConfigReset(
span=expr.span,
)

elif isinstance(info.param_type, s_objtypes.ObjectType):
if (
expr.scope == qltypes.ConfigScope.INSTANCE and
info.backend_setting == 'default_transaction_isolation'
):
# Special case for default_transaction_isolation:
# Gel default is `serializable`, while PG default is `read committed`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this out as a HACK in the comments.
Some day we may want this to be a general mechanism?
(Not today.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, now that I'm thinking more about it, maybe we should always reset the system backend settings to their Gel defaults explicitly, as we cannot rely on the backend defaults, like users could put anything in postgresql.conf and run Gel with --backend-dsn.

default = info.ptr.get_default(ctx.env.schema)
if default is not None:
return compile_ConfigSet(
qlast.ConfigSet(
name=expr.name,
scope=expr.scope,
expr=default.parse(),
),
ctx=ctx,
)

if isinstance(info.param_type, s_objtypes.ObjectType):
param_type_name = info.param_type.get_name(ctx.env.schema)
param_type_ref = qlast.ObjectRef(
name=param_type_name.name,
Expand Down
6 changes: 6 additions & 0 deletions edb/server/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,7 @@ async def _configure(
await _execute_block(ctx.conn, block)

backend_params = ctx.cluster.get_runtime_params()
need_reload = False
for setname in config_spec:
setting = config_spec[setname]
if (
Expand All @@ -1984,9 +1985,12 @@ async def _configure(
# backends that don't support it.
# TODO: this should be replaced by instance-wide
# emulation at backend connection time.
# fantix: +1 to the above, also needed by
# `default_transaction_isolation=serializable`
backend_params.has_configfile_access
)
):
need_reload = True
script = qlcodegen.generate_source(
qlast.ConfigSet(
name=qlast.ObjectRef(name=setting.name),
Expand All @@ -1996,6 +2000,8 @@ async def _configure(
)
schema, sql = compile_bootstrap_script(compiler, schema, script)
await _execute(ctx.conn, sql)
if need_reload:
await _execute(ctx.conn, 'SELECT pg_reload_conf()')


def compile_sys_queries(
Expand Down
8 changes: 5 additions & 3 deletions edb/server/pgcluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
'timezone': 'UTC',
'intervalstyle': 'iso_8601',
'jit': 'off',
'default_transaction_isolation': 'serializable',
}


Expand Down Expand Up @@ -497,6 +496,7 @@ async def ensure_initialized(self, **settings: Any) -> bool:

have_c_utf8 = self.get_runtime_params().has_c_utf8_locale
await self.init(
"default_transaction_isolation='serializable'",
username='postgres',
locale='C.UTF-8' if have_c_utf8 else 'en_US.UTF-8',
lc_collate='C',
Expand All @@ -513,16 +513,18 @@ async def ensure_initialized(self, **settings: Any) -> bool:
else:
return False

async def init(self, **settings: str) -> None:
async def init(self, *server_config: str, **settings: str) -> None:
"""Initialize cluster."""
if await self.get_status() != 'not-initialized':
raise ClusterError(
'cluster in {!r} has already been initialized'.format(
self._data_dir))

if settings:
if settings or server_config:
settings_args = ['--{}={}'.format(k.replace('_', '-'), v)
for k, v in settings.items()]
for conf in server_config:
settings_args.append('-c {}'.format(conf))
extra_args = ['-o'] + [' '.join(settings_args)]
else:
extra_args = []
Expand Down
Loading