-
Notifications
You must be signed in to change notification settings - Fork 455
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
Use rust bindgen for reading/writing the PostgreSQL control file. #6
Conversation
My findings so far on the use of Since I hoped there would be a way to attach I also looked around at some of the "safe transmute" crates and RFC 2981. While there is a lot of potential there, I didn't find anything that's able to solve this problem now. Some possible ways forward: (d) seems crude, but it's so much less work than (c) that I think it's probably the right way forward, unless we expect to only have a few C structs imported with bindgen, then handwritten is probably fine. |
Perhaps we could map Postgres
Yeah, that would've been nice.
I'm inclined to do a) for now, and revisit this and perhaps switch to d) if we need many more of these structs. If we're lucky, this gets addressed in bindgen in the meanwhile. We have a few hand-written structs in the WAL decoding routines that mirror Postgres structs, but those are fairly short and we only need to read them, not write. But if we had a more general solution, would be nice to use it for those too. |
I looked for a way to tell bindgen to remap |
Do we want to be able to convert Right now it looks like there's a copy happening, unless the compiler can optimize it away. |
There's an (undocumented?) standard practice in Rust, which is that whenever you use // SAFETY: the align is guaranteed by Rust to be a power of two and
// the size+align combo is guaranteed to fit in our address space. As a
// result use the unchecked constructor here to avoid inserting code
// that panics if it isn't optimized well enough.
unsafe { Layout::from_size_align_unchecked(size, align) } |
Should this be closed? The code was merged a while ago under another PR. |
Yeah, I'll close this. We had some good discussion and suggestion here, but nothing concrete pending. |
## Problem Running test_pageserver_restarts_under_workload in POR #7275 I get the following assertion failure in prefetch: ``` #5 0x00005587220d4bf0 in ExceptionalCondition ( conditionName=0x7fbf24d003c8 "(ring_index) < MyPState->ring_unused && (ring_index) >= MyPState->ring_last", fileName=0x7fbf24d00240 "/home/knizhnik/neon.main//pgxn/neon/pagestore_smgr.c", lineNumber=644) at /home/knizhnik/neon.main//vendor/postgres-v16/src/backend/utils/error/assert.c:66 #6 0x00007fbf24cebc9b in prefetch_set_unused (ring_index=1509) at /home/knizhnik/neon.main//pgxn/neon/pagestore_smgr.c:644 #7 0x00007fbf24cec613 in prefetch_register_buffer (tag=..., force_latest=0x0, force_lsn=0x0) at /home/knizhnik/neon.main//pgxn/neon/pagestore_smgr.c:891 #8 0x00007fbf24cef21e in neon_prefetch (reln=0x5587233b7388, forknum=MAIN_FORKNUM, blocknum=14110) at /home/knizhnik/neon.main//pgxn/neon/pagestore_smgr.c:2055 (gdb) p ring_index $1 = 1509 (gdb) p MyPState->ring_unused $2 = 1636 (gdb) p MyPState->ring_last $3 = 1636 ``` ## Summary of changes Check status of `prefetch_wait_for` ## 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>
No description provided.