Repository: edgedb/edgedb

Issue:
Unable to set `effective_io_concurrency` via CLI or REPL (`InternalServerError` when attempting from the REPL)
<!-- Please search existing issues to avoid creating duplicates. -->

<!--
For the EdgeDB Version: run `edgedb query 'select sys::get_version_as_str()'` from your project directory (or run `select sys::get_version_as_str();` in the EdgeDB interactive shell).
For the EdgeDB CLI Version: Run `edgedb --version` from anywhere
-->

- EdgeDB Version: 3.3+d5734dd
- EdgeDB CLI Version: 3.5.0+e1ad387
- OS Version: macOS 13.4.1

Steps to Reproduce:

1. Start a new project (`edgedb project init`)
2. Attempt to set `effective_io_concurrency`

via CLI
```
$ edgedb configure set effective_io_concurrency 10
edgedb error: ConfigurationError: invalid setting value type for effective_io_concurrency: 'std::str' (expecting 'std::int64')
…
$ edgedb configure set effective_io_concurrency <int64>10
zsh: no such file or directory: int64
$ edgedb configure set effective_io_concurrency \<int64\>10
edgedb error: ConfigurationError: invalid setting value type for effective_io_concurrency: 'std::str' (expecting 'std::int64')
…
$ edgedb configure set effective_io_concurrency "<int64>10"edgedb error: ConfigurationError: invalid setting value type for effective_io_concurrency: 'std::str' (expecting 'std::int64')
```

or via REPL:
```
edgedb> configure instance set effective_io_concurrency := 10;
edgedb error: InternalServerError: None
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 134, in compile_ir_to_sql_tree
          qtree = dispatch.compile(ir_expr, ctx=ctx)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/functools.py", line 909, in wrapper
          return dispatch(args[0].__class__)(*args, **kw)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/config.py", line 48, in compile_ConfigSet
          val = _compile_config_value(op, ctx=ctx)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/config.py", line 476, in _compile_config_value
          assert op.backend_expr is not None
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AssertionError

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler_pool/worker.py", line 161, in compile
          units, cstate = COMPILER.compile(
                          ^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 856, in compile
          unit_group = compile(ctx=ctx, source=source)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 2045, in compile
          return _try_compile(ctx=ctx, source=source)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 2113, in _try_compile
          comp, capabilities = _compile_dispatch_ql(
                               ^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 1999, in _compile_dispatch_ql
          _compile_ql_config_op(ctx, ql),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 1890, in _compile_ql_config_op
          sql_text, _ = pg_compiler.compile_ir_to_sql(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 227, in compile_ir_to_sql
          _, sql_text, argmap = compile_ir_to_tree_and_sql(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 169, in compile_ir_to_tree_and_sql
          qtree, _ = compile_ir_to_sql_tree(
                     ^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 151, in compile_ir_to_sql_tree
          raise errors.InternalServerError(*args) from e
      edb.errors.InternalServerError: None
edgedb> configure instance set effective_io_concurrency := <int64>10;
edgedb error: InternalServerError: None
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 134, in compile_ir_to_sql_tree
          qtree = dispatch.compile(ir_expr, ctx=ctx)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/functools.py", line 909, in wrapper
          return dispatch(args[0].__class__)(*args, **kw)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/config.py", line 48, in compile_ConfigSet
          val = _compile_config_value(op, ctx=ctx)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/config.py", line 476, in _compile_config_value
          assert op.backend_expr is not None
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AssertionError

      The above exception was the direct cause of the following exception:

      Traceback (most recent call last):
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler_pool/worker.py", line 161, in compile
          units, cstate = COMPILER.compile(
                          ^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 856, in compile
          unit_group = compile(ctx=ctx, source=source)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 2045, in compile
          return _try_compile(ctx=ctx, source=source)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 2113, in _try_compile
          comp, capabilities = _compile_dispatch_ql(
                               ^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 1999, in _compile_dispatch_ql
          _compile_ql_config_op(ctx, ql),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/server/compiler/compiler.py", line 1890, in _compile_ql_config_op
          sql_text, _ = pg_compiler.compile_ir_to_sql(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 227, in compile_ir_to_sql
          _, sql_text, argmap = compile_ir_to_tree_and_sql(
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 169, in compile_ir_to_tree_and_sql
          qtree, _ = compile_ir_to_sql_tree(
                     ^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/raddevon/Library/Application Support/edgedb/portable/3.3/lib/python3.11/site-packages/edb/pgsql/compiler/__init__.py", line 151, in compile_ir_to_sql_tree
          raise errors.InternalServerError(*args) from e
      edb.errors.InternalServerError: None
```

<!-- If the issue is about a query error, please also provide your schema -->

Schema:



Discussion:

Resolving patch:
diff --git a/edb/pgsql/compiler/config.py b/edb/pgsql/compiler/config.py
--- a/edb/pgsql/compiler/config.py
+++ b/edb/pgsql/compiler/config.py
@@ -625,11 +625,7 @@ def _compile_config_value(
 ) -> pgast.BaseExpr:
     val: pgast.BaseExpr
 
-    if op.backend_setting:
-        assert op.backend_expr is not None
-        expr = op.backend_expr
-    else:
-        expr = op.expr
+    expr = op.backend_expr or op.expr
 
     with ctx.new() as subctx:
         if op.backend_setting or op.scope == qltypes.ConfigScope.GLOBAL:


Test patch:
diff --git a/tests/test_server_config.py b/tests/test_server_config.py
--- a/tests/test_server_config.py
+++ b/tests/test_server_config.py
@@ -1726,6 +1726,14 @@ async def assert_conf(con, name, expected_val):
                     cur_shared[0]
                 )
 
+                cur_eff = await c1.query_single('''
+                    select assert_single(cfg::Config.effective_io_concurrency)
+                ''')
+                await c1.query(f'''
+                    configure instance set
+                        effective_io_concurrency := {cur_eff}
+                ''')
+
                 await c1.aclose()
                 await c2.aclose()
                 await t1.aclose()