-
Notifications
You must be signed in to change notification settings - Fork 446
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
Fix issues with prefetch ring buffer resize #9847
base: main
Are you sure you want to change the base?
Conversation
5625 tests run: 5389 passed, 0 failed, 236 skipped (full report)Code coverage* (full report)
* collected from Rust tests only The comment gets automatically updated with the latest test results
85bc9b9 at 2024-11-23T09:35:02.523Z :recycle: |
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 patch looks correct to me. See my comment on the "Change prefetch buffer overflow criteria" part though.
readahead_buffer_resize() is called from the GUC's assign hook. If readahead_buffer_resize() throws an error for any reason (OOM, network error etc.), that could be a problem. The GUC is marked as PGC_USERSET, so its value might need to be changed e.g on transaction abort, or by RESET ALL, and it would be unpleasant if that would fail. But that's not new in this PR.
In general it would feel less error-prone if we'd just throw away all prefetched state, disconnect all connections, and start from scratch.
if (MyPState->ring_last + readahead_buffer_size - 1 == MyPState->ring_unused) | ||
if (MyPState->ring_last + readahead_buffer_size == MyPState->ring_unused) |
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 is very subtle. Is this related to resizing, or an unrelated improvement? I'd suggest opening a separate PR.
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.
It is actually the main ;problem fixed by this PR.
This check assumes that we use not more than readahead_buffer_size - 1
elements in prefetch buffer.
But readahead_buffer_resize
can fill completely (all readahead_buffer_size
elements). In this case this check will Neve fired and we will overwrite old entries without freeing them.
Looks correct. AFAICS prefetch_set_unused() worked too, though. This is just an optimization to avoid unnecessary work on the old prefetching queue that we are about to throw away anyway, right? Maybe add a comment on that. |
I was not 100% sure about use of |
Problem
See https://neondb.slack.com/archives/C04DGM6SMTM/p1732110190129479
We observe the following error in the logs
most likely caused by changing
neon.readahead_buffer_size
Summary of changes