mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-10 15:02:56 +00:00
Run each migration in its own transaction
Previously, every migration was run in the same transaction. This is preparatory work for fixing CVE-2024-4317.
This commit is contained in:
committed by
Tristan Partin
parent
b5ab055526
commit
ba17025a57
@@ -3798,13 +3798,13 @@ class Endpoint(PgProtocol, LogUtils):
|
||||
json.dump(dict(data_dict, **kwargs), file, indent=4)
|
||||
|
||||
# Please note: Migrations only run if pg_skip_catalog_updates is false
|
||||
def wait_for_migrations(self):
|
||||
def wait_for_migrations(self, num_migrations: int = 10):
|
||||
with self.cursor() as cur:
|
||||
|
||||
def check_migrations_done():
|
||||
cur.execute("SELECT id FROM neon_migration.migration_id")
|
||||
migration_id = cur.fetchall()[0][0]
|
||||
assert migration_id != 0
|
||||
migration_id: int = cur.fetchall()[0][0]
|
||||
assert migration_id >= num_migrations
|
||||
|
||||
wait_until(20, 0.5, check_migrations_done)
|
||||
|
||||
|
||||
@@ -11,17 +11,14 @@ def test_migrations(neon_simple_env: NeonEnv):
|
||||
endpoint.respec(skip_pg_catalog_updates=False)
|
||||
endpoint.start()
|
||||
|
||||
endpoint.wait_for_migrations()
|
||||
|
||||
num_migrations = 10
|
||||
endpoint.wait_for_migrations(num_migrations=num_migrations)
|
||||
|
||||
with endpoint.cursor() as cur:
|
||||
cur.execute("SELECT id FROM neon_migration.migration_id")
|
||||
migration_id = cur.fetchall()
|
||||
assert migration_id[0][0] == num_migrations
|
||||
|
||||
endpoint.assert_log_contains(f"INFO handle_migrations: Ran {num_migrations} migrations")
|
||||
|
||||
endpoint.stop()
|
||||
endpoint.start()
|
||||
# We don't have a good way of knowing that the migrations code path finished executing
|
||||
@@ -31,5 +28,3 @@ def test_migrations(neon_simple_env: NeonEnv):
|
||||
cur.execute("SELECT id FROM neon_migration.migration_id")
|
||||
migration_id = cur.fetchall()
|
||||
assert migration_id[0][0] == num_migrations
|
||||
|
||||
endpoint.assert_log_contains("INFO handle_migrations: Ran 0 migrations")
|
||||
|
||||
Reference in New Issue
Block a user