Skip to content
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

Remember last written LSN when it is first requested #411

Merged
merged 4 commits into from
Apr 10, 2024

Conversation

knizhnik
Copy link

@knizhnik knizhnik commented Apr 8, 2024

See https://neondb.slack.com/archives/C03QLRH7PPD/p1712529369520409

In case of statements CREATE TABLE AS SELECT... or INSERT FROM SELECT... we are fetching data from source table and storing it in destination table. It cause problems with prefetch last-written-lsn is known for the pages of source table
(which for example happens after compute restart). In this case we get get global value of last-written-lsn which is changed frequently as far as we are writing pages of destination table. As a result request-isn for the prefetch and request-let when this page is actually needed are different and we got exported prefetch request. So it actually disarms prefetch.

Proposed simple patch stores last-written LSN for the page when it is not found. So next time we will request last-written LSN for this page, we will get the same value (certainly if the page was not changed).

Copy link

@MMeent MMeent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 👍

}

/*
* SetLastWrittenLSNForRelation -- Set maximal LSN for relation metadata
*/
void

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, too: Not a fan of the additional newline, but won't block it on this.

@knizhnik knizhnik merged commit 85d809c into REL_15_STABLE_neon Apr 10, 2024
@knizhnik knizhnik deleted the remember_last_written_lsn_v15 branch April 10, 2024 18:06
tristan957 pushed a commit that referenced this pull request May 10, 2024
* Remember last written LSN when it is first requested

* Use rnode instead of rlocator

* Return updated LSN in SetLastWrittenLSN

* Remove wrong new line

---------

Co-authored-by: Konstantin Knizhnik <[email protected]>
tristan957 pushed a commit that referenced this pull request May 20, 2024
* Remember last written LSN when it is first requested

* Use rnode instead of rlocator

* Return updated LSN in SetLastWrittenLSN

* Remove wrong new line

---------

Co-authored-by: Konstantin Knizhnik <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants