Skip to content

Commit

Permalink
Fix SQL introspection after inplace upgrade (#8159)
Browse files Browse the repository at this point in the history
We need to refresh the views after the upgrade.
Fixes #8155.
  • Loading branch information
msullivan committed Jan 3, 2025
1 parent 07f5856 commit d9b6dfa
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
14 changes: 10 additions & 4 deletions edb/server/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ async def test() -> None:
started = time.monotonic()
await test()
left -= (time.monotonic() - started)
if res := self._admin_query("SELECT ();", f"{max(1, int(left))}s"):
if res := self._admin_query(
"SELECT ();",
f"{max(1, int(left))}s",
check=False,
):
raise ClusterError(
f'could not connect to edgedb-server '
f'within {timeout} seconds (exit code = {res})') from None
Expand All @@ -333,6 +337,7 @@ def _admin_query(
self,
query: str,
wait_until_available: str = "0s",
check: bool=True,
) -> int:
args = [
"edgedb",
Expand All @@ -350,12 +355,13 @@ def _admin_query(
wait_until_available,
query,
]
res = subprocess.call(
res = subprocess.run(
args=args,
stdout=subprocess.DEVNULL,
check=check,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
return res
return res.returncode

async def set_test_config(self) -> None:
self._admin_query(f'''
Expand Down
10 changes: 10 additions & 0 deletions edb/server/inplace_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

from edb.pgsql import common as pg_common
from edb.pgsql import dbops
from edb.pgsql import metaschema
from edb.pgsql import trampoline


Expand Down Expand Up @@ -273,6 +274,15 @@ async def _upgrade_one(
except Exception:
raise

# Refresh the pg_catalog materialized views
current_block = dbops.PLTopBlock()
refresh = metaschema.generate_sql_information_schema_refresh(
backend_params.instance_params.version
)
refresh.generate(current_block)
patch = current_block.to_string()
await ctx.conn.sql_execute(patch.encode('utf-8'))

new_local_spec = config.load_spec_from_schema(
schema,
only_exts=True,
Expand Down
3 changes: 3 additions & 0 deletions tests/inplace-testing/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ if $EDGEDB query 'create empty branch asdf'; then
fi
$EDGEDB query 'configure instance reset force_database_error'
stop_server
if [ "$SAVE_TARBALLS" = 1 ]; then
tar cf "$DIR"-cooked2.tar "$DIR"
fi


# Test!
Expand Down

0 comments on commit d9b6dfa

Please sign in to comment.