mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-25 15:19:58 +00:00
Use smgrexists() instead of access() to enforce uniqueness of generated relfilenumber (#7992)
## Problem Postgres is using `access()` function in `GetNewRelFileNumber` to check if assigned relfilenumber is not used for any other relation. This check will not work in Neon, because we do not have all files in local storage. ## Summary of changes Use smgrexists() instead which will check at page server if such relfilenode is used. ## Checklist before requesting a review - [ ] I have performed a self-review of my code. - [ ] If it is a core feature, I have added thorough tests. - [ ] Do we need to implement analytics? if so did you add the relevant metrics to the dashboard? - [ ] If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section. ## Checklist before merging - [ ] Do not forget to reformat commit message to not include the above checklist --------- Co-authored-by: Konstantin Knizhnik <knizhnik@neon.tech>
This commit is contained in:
committed by
GitHub
parent
1a4c1eba92
commit
563d73d923
45
test_runner/regress/test_oid_overflow.py
Normal file
45
test_runner/regress/test_oid_overflow.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from fixtures.log_helper import log
|
||||
from fixtures.neon_fixtures import NeonEnvBuilder
|
||||
|
||||
|
||||
def test_oid_overflow(neon_env_builder: NeonEnvBuilder):
|
||||
env = neon_env_builder.init_start()
|
||||
|
||||
endpoint = env.endpoints.create_start("main")
|
||||
|
||||
conn = endpoint.connect()
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute("CREATE EXTENSION neon_test_utils")
|
||||
|
||||
cur.execute("CREATE TABLE t1(x integer)")
|
||||
cur.execute("INSERT INTO t1 values (1)")
|
||||
cur.execute("CREATE TABLE t2(x integer)")
|
||||
cur.execute("INSERT INTO t2 values (2)")
|
||||
|
||||
cur.execute("SELECT x from t1")
|
||||
assert cur.fetchone() == (1,)
|
||||
cur.execute("SELECT x from t2")
|
||||
assert cur.fetchone() == (2,)
|
||||
|
||||
cur.execute("VACUUM FULL t1")
|
||||
cur.execute("VACUUM FULL t1")
|
||||
cur.execute("vacuum pg_class")
|
||||
cur.execute("SELECT relfilenode FROM pg_class where relname='t1'")
|
||||
oid = cur.fetchall()[0][0]
|
||||
log.info(f"t1.relfilenode={oid}")
|
||||
|
||||
cur.execute("set statement_timeout=0")
|
||||
cur.execute(f"select test_consume_oids({oid-1})")
|
||||
cur.execute("VACUUM FULL t2")
|
||||
|
||||
cur.execute("SELECT relfilenode FROM pg_class where relname='t2'")
|
||||
oid = cur.fetchall()[0][0]
|
||||
log.info(f"t2.relfilenode={oid}")
|
||||
|
||||
cur.execute("SELECT clear_buffer_cache()")
|
||||
|
||||
cur.execute("SELECT x from t1")
|
||||
assert cur.fetchone() == (1,)
|
||||
cur.execute("SELECT x from t2")
|
||||
assert cur.fetchone() == (2,)
|
||||
Reference in New Issue
Block a user