-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use smgrexists() instead of access() to enforce uniqueness of generat…
…ed 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 <[email protected]>
- Loading branch information
Showing
8 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"v16": ["16.3", "b810fdfcbb59afea7ea7bbe0cf94eaccb55a2ea2"], | ||
"v15": ["15.7", "4874c8e52ed349a9f8290bbdcd91eb92677a5d24"], | ||
"v14": ["14.12", "ad73770c446ea361f43e4f0404798b7e5e7a62d8"] | ||
"v16": ["16.3", "b39f316137fdd29e2da15d2af2fdd1cfd18163be"], | ||
"v15": ["15.7", "035b73a9c5998f9a0ef35cc8df1bae680bf770fc"], | ||
"v14": ["14.12", "dbd0e6428b9274d72a10ac29bd3e3162faf109d4"] | ||
} |
563d73d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3214 tests run: 3080 passed, 1 failed, 133 skipped (full report)
Failures on Postgres 16
test_multixid_wraparound_import
: releaseTest coverage report is not available
563d73d at 2024-07-23T17:14:34.254Z :recycle: