From d9b6dfaef0a7588ed4ac842dcdbbb98da6936cb7 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Thu, 2 Jan 2025 19:15:22 -0800 Subject: [PATCH] Fix SQL introspection after inplace upgrade (#8159) We need to refresh the views after the upgrade. Fixes #8155. --- edb/server/cluster.py | 14 ++++++++++---- edb/server/inplace_upgrade.py | 10 ++++++++++ tests/inplace-testing/test.sh | 3 +++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/edb/server/cluster.py b/edb/server/cluster.py index 6b9a55e1a31..6f4524bb06f 100644 --- a/edb/server/cluster.py +++ b/edb/server/cluster.py @@ -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 @@ -333,6 +337,7 @@ def _admin_query( self, query: str, wait_until_available: str = "0s", + check: bool=True, ) -> int: args = [ "edgedb", @@ -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''' diff --git a/edb/server/inplace_upgrade.py b/edb/server/inplace_upgrade.py index d07ca92bee6..86b9c4551b2 100644 --- a/edb/server/inplace_upgrade.py +++ b/edb/server/inplace_upgrade.py @@ -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 @@ -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, diff --git a/tests/inplace-testing/test.sh b/tests/inplace-testing/test.sh index f7265fc1e20..d3ac8012738 100755 --- a/tests/inplace-testing/test.sh +++ b/tests/inplace-testing/test.sh @@ -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!