pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: De-pessimize ConditionVariableCancelSleep(). 2+ messages / 1 participants [nested] [flat]
* pgsql: De-pessimize ConditionVariableCancelSleep(). @ 2023-08-14 22:46 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Thomas Munro @ 2023-08-14 22:46 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org De-pessimize ConditionVariableCancelSleep(). Commit b91dd9de was concerned with a theoretical problem with our non-atomic condition variable operations. If you stop sleeping, and then cancel the sleep in a separate step, you might be signaled in between, and that could be lost. That doesn't matter for callers of ConditionVariableBroadcast(), but callers of ConditionVariableSignal() might be upset if a signal went missing like this. Commit bc971f4025c interacted badly with that logic, because it doesn't use ConditionVariableSleep(), which would normally put us back in the wait list. ConditionVariableCancelSleep() would be confused and think we'd received an extra signal, and try to forward it to another backend, resulting in wakeup storms. New idea: ConditionVariableCancelSleep() can just return true if we've been signaled. Hypothetical users of ConditionVariableSignal() would then still have a way to deal with rare lost signals if they are concerned about that problem. Back-patch to 16, where bc971f4025c arrived. Reported-by: Tomas Vondra <tomas.vondra@enterprisedb.com> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/2840876b-4cfe-240f-0a7e-29ffd66711e7%40enterprisedb.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/5ffb7c775062ef18756e515ac96f06d012cbb950 Modified Files -------------- src/backend/storage/lmgr/condition_variable.c | 16 ++++++---------- src/include/storage/condition_variable.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: De-pessimize ConditionVariableCancelSleep(). @ 2023-08-14 22:46 Thomas Munro <tmunro@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Thomas Munro @ 2023-08-14 22:46 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org De-pessimize ConditionVariableCancelSleep(). Commit b91dd9de was concerned with a theoretical problem with our non-atomic condition variable operations. If you stop sleeping, and then cancel the sleep in a separate step, you might be signaled in between, and that could be lost. That doesn't matter for callers of ConditionVariableBroadcast(), but callers of ConditionVariableSignal() might be upset if a signal went missing like this. Commit bc971f4025c interacted badly with that logic, because it doesn't use ConditionVariableSleep(), which would normally put us back in the wait list. ConditionVariableCancelSleep() would be confused and think we'd received an extra signal, and try to forward it to another backend, resulting in wakeup storms. New idea: ConditionVariableCancelSleep() can just return true if we've been signaled. Hypothetical users of ConditionVariableSignal() would then still have a way to deal with rare lost signals if they are concerned about that problem. Back-patch to 16, where bc971f4025c arrived. Reported-by: Tomas Vondra <tomas.vondra@enterprisedb.com> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/2840876b-4cfe-240f-0a7e-29ffd66711e7%40enterprisedb.com Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/acc5c4fd8f83e5991cab11d7299d112e89cb3fe7 Modified Files -------------- src/backend/storage/lmgr/condition_variable.c | 16 ++++++---------- src/include/storage/condition_variable.h | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2023-08-14 22:46 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-08-14 22:46 pgsql: De-pessimize ConditionVariableCancelSleep(). Thomas Munro <tmunro@postgresql.org> 2023-08-14 22:46 pgsql: De-pessimize ConditionVariableCancelSleep(). Thomas Munro <tmunro@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox