From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Cc: | exclusion(at)gmail(dot)com, michael(at)paquier(dot)xyz |
Subject: | Fix race condition in InvalidatePossiblyObsoleteSlot() |
Date: | 2024-01-15 07:48:43 |
Message-ID: | ZaTjW2Xh+TQUCOH0@ip-10-97-1-34.eu-west-3.compute.internal |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi hackers,
While working on [1], we discovered (thanks Alexander for the testing) that an
conflicting active logical slot on a standby could be "terminated" without
leading to an "obsolete" message (see [2]).
Indeed, in case of an active slot we proceed in 2 steps in
InvalidatePossiblyObsoleteSlot():
- terminate the backend holding the slot
- report the slot as obsolete
This is racy because between the two we release the mutex on the slot, which
means that the slot's effective_xmin and effective_catalog_xmin could advance
during that time (leading to exit the loop).
I think that holding the mutex longer is not an option (given what we'd to do
while holding it) so the attached proposal is to record the effective_xmin and
effective_catalog_xmin instead that was used during the backend termination.
[1]: https://www.postgresql.org/message-id/flat/bf67e076-b163-9ba3-4ade-b9fc51a3a8f6%40gmail.com
[2]: https://www.postgresql.org/message-id/7c025095-5763-17a6-8c80-899b35bd0459%40gmail.com
Looking forward to your feedback,
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Fix-race-condition-in-InvalidatePossiblyObsoleteS.patch | text/x-diff | 2.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tatsuo Ishii | 2024-01-15 07:49:44 | Re: pgbnech: allow to cancel queries during benchmark |
Previous Message | Masahiko Sawada | 2024-01-15 07:03:41 | Re: Make COPY format extendable: Extract COPY TO format implementations |