Compare commits

...

3 Commits

Author SHA1 Message Date
Konstantin Knizhnik
613f52cb9d Fix test_vm_bits test 2024-01-21 20:54:06 +02:00
Konstantin Knizhnik
3d9b8c8c6d Make ruff happy 2024-01-21 20:54:06 +02:00
Konstantin Knizhnik
10bd1669a6 Fix XID comparison in test_vm_bit_clear_on_heap_lock test 2024-01-21 20:54:06 +02:00

View File

@@ -1,4 +1,3 @@
import pytest
from fixtures.log_helper import log
from fixtures.neon_fixtures import NeonEnv, fork_at_current_lsn
@@ -118,8 +117,6 @@ def test_vm_bit_clear(neon_simple_env: NeonEnv):
# Test that the ALL_FROZEN VM bit is cleared correctly at a HEAP_LOCK
# record.
#
# FIXME: This test is broken
@pytest.mark.skip("See https://github.com/neondatabase/neon/pull/6412#issuecomment-1902072541")
def test_vm_bit_clear_on_heap_lock(neon_simple_env: NeonEnv):
env = neon_simple_env
@@ -153,7 +150,7 @@ def test_vm_bit_clear_on_heap_lock(neon_simple_env: NeonEnv):
# Remember the XID. We will use it later to verify that we have consumed a lot of
# XIDs after this.
cur.execute("select pg_current_xact_id()")
locking_xid = cur.fetchall()[0][0]
locking_xid = int(cur.fetchall()[0][0])
# Stop and restart postgres, to clear the buffer cache.
#
@@ -194,17 +191,17 @@ def test_vm_bit_clear_on_heap_lock(neon_simple_env: NeonEnv):
tup = cur.fetchall()
log.info(f"tuple = {tup}")
xmax = tup[0][1]
assert xmax == xmax_before
assert xmax == "0" or xmax == xmax_before
if i % 50 == 0:
cur.execute("select datfrozenxid from pg_database where datname='postgres'")
datfrozenxid = cur.fetchall()[0][0]
datfrozenxid = int(cur.fetchall()[0][0])
if datfrozenxid > locking_xid:
break
cur.execute("select pg_current_xact_id()")
curr_xid = cur.fetchall()[0][0]
assert int(curr_xid) - int(locking_xid) >= 100000
curr_xid = int(cur.fetchall()[0][0])
assert curr_xid - locking_xid >= 100000
# Now, if the VM all-frozen bit was not correctly cleared on
# replay, we will try to fetch the status of the XID that was
@@ -214,3 +211,4 @@ def test_vm_bit_clear_on_heap_lock(neon_simple_env: NeonEnv):
cur.execute("select xmin, xmax, * from vmtest_lock where id = 40000 for update")
tup = cur.fetchall()
log.info(f"tuple = {tup}")
cur.execute("commit transaction")