Skip to content

fix: incorrect shared memory setup #222

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

Merged
merged 2 commits into from
Aug 5, 2025

Conversation

steve-chavez
Copy link
Member

@steve-chavez steve-chavez commented Aug 4, 2025

Before the shared memory wasn't guarded with lwlocks plus there was no call to RequestAddinShmemSpace to estimate used memory (the latter only available on pg >= 15).

Closes #220

@steve-chavez steve-chavez requested a review from za-arthur August 4, 2025 16:03
@steve-chavez steve-chavez marked this pull request as draft August 4, 2025 16:04
@steve-chavez steve-chavez marked this pull request as ready for review August 4, 2025 16:17
@steve-chavez steve-chavez requested review from za-arthur and removed request for za-arthur August 4, 2025 16:17
Copy link

@za-arthur za-arthur left a comment

Choose a reason for hiding this comment

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

Before the shared memory wasn't guarded with lwlocks plus there was no call to RequestAddinShmemSpace to estimate used memory (the latter only available on pg >= 15).

Thank you for the PR! I think RequestAddinShmemSpace() itself is available before Postgres 15, but indeed shmem_request_hook hook was added on Postgres 15 only. Before 15 extensions were requesting memory within _PG_init() typically. See:

https://github.com/postgres/postgres/blob/REL_14_18/contrib/pg_prewarm/autoprewarm.c#L141

And here is the commit which changed it:

postgres/postgres@4f2400c#diff-ffc42154e133dc207f731ed03bda00d70946ec7533ed67447b8e143e32c059dfR142-R145

I added this suggestion below.

Before the shared memory wasn't guarded with lwlocks plus there was no
call to RequestAddinShmemSpace to estimate used memory.

Closes supabase#220
@steve-chavez
Copy link
Member Author

@za-arthur Many thanks for the review 💚. Already made the changes.

Copy link

@za-arthur za-arthur left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM.

@steve-chavez steve-chavez merged commit a7792bf into supabase:master Aug 5, 2025
11 of 12 checks passed
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.

Correctly initialize shared memory
2 participants