-
Notifications
You must be signed in to change notification settings - Fork 17
Update last written LSN for gin/gist index metadata #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
For some reason, I didn't receive notification for review requested in this PR. LGTM, but let's wait for CIs in https://github.com/neondatabase/neon/tree/exp-07-18 to make sure tests with the new changes passed.
src/backend/access/gin/gininsert.c
Outdated
SetLastWrittenLSN(XactLastRecEnd, index->rd_smgr->smgr_rnode.node.relNode, 0, RelationGetNumberOfBlocks(index)); | ||
SetLastWrittenLSN(XactLastRecEnd, index->rd_smgr->smgr_rnode.node.relNode, REL_METADATA_PSEUDO_BLOCKNO, REL_METADATA_PSEUDO_BLOCKNO); |
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.
This API where you have to call SetLastWrittenLSN twice, is a bit awkward. In all of these calls where you pass REL_METADATA_PSEUDO_BLOCKNO, you have just loaded the relation with data. How replacing SetLastWrittenLSN() with two functions:
SetLastWrittenLSNForRelation(Relation, ForkNumber, XLogRecPtr);
SetLastWrittenLSNForBlock(RelFileNode, ForkNumber, BlockNumber, XLogRecPtr);
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.
Done
thanks! |
/* | ||
* Pseudo block number used to associate LSN with relation metadata (relation size) | ||
*/ | ||
#define REL_METADATA_PSEUDO_BLOCKNO InvalidBlockNumber | ||
|
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.
You can move this back here
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.
Unfortunately - not, it is use in pagestore_smgr.c in zenith_get_request_lsn
-> GeLastWrittenLsn
.
Certainly it is possible to add two versions of GetLastWrittenLsn
function and somehow explain zenith_get_request_lsn
which version to call. But it complicates code and I am not sure that it makes it ore readable. So I left it as it is.
Got a CI failure with this:
|
I can not reproduce the problem with test_recovery failure locally, did you? Or it just happens in CI? Certainly, if there are such errors and this patch is blocking other patches, then it should be undone. Also I have implemented version of last written LSN cache which uses buffer tag as a key: So, if we undo this commits, what do you think will be the next steps with this PR? But first of all it will be nice to understand the reason of this failure... |
That works, but requires a force-push. I'd suggest Yeah, please go ahead and do the revert. Let's unblock the uuid-ossp change, and get vendor/postgres back in sync with the postgres main-branch again.
It's more about readability; it's surprising to use just the relfilenode oid as the key. I don't feel strongly about it, but unless you can see a measurable, significant performance difference, I would prefer using the buffer tag.
I think the high-level approach here makes sense, we're just talking about the details.
Agreed. It certainly looks like an LSN-cache related bug, but in any case we need to find the bug. |
I tried to run CI test with this postgres versions. |
One possible cause is that this patch slows down the performance of those tests. That said, I wasn't able to reproduce the failures locally when running tests individually. Maybe, running in parallel would be different. The same tests also fail in https://app.circleci.com/pipelines/github/neondatabase/neon/8175/workflows/96416e07-8028-46d0-94d7-2a470ae42425/jobs/83642. They're consistent, so definitely there is something wrong here. |
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
* Update last written LSN for gin/gist index metadata * Replace SetLastWrittenLSN with family of SetLastWrittenLSNFFor* functions
This commit fix the problem with pg_regress with last_written_lsn_cache.
Indexes which are populated in special way (gin,gist,spgist,...) requires update of last written LSN for relation metadata