Introduce timeout capability for ConditionVariableSleep
Shawn Debnath <sdn@amazon.com>
From: Shawn Debnath <sdn@amazon.com>
To: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2019-03-12T23:24:54Z
Lists: pgsql-hackers
Attachments
Hello, Postgres today doesn't support waiting for a condition variable with a timeout, although the framework it relies upon, does. This change wraps the existing ConditionVariableSleep functionality and introduces a new API, ConditionVariableTimedSleep, to allow callers to specify a timeout value. A scenario that highlights this use case is a backend is waiting on status update from multiple workers but needs to time out if that signal doesn't arrive within a certain period. There was a workaround prior to aced5a92, but with that change, the semantics are now different. I chose to go with -1 instead of 0 for the return from ConditionVariableTimedSleep to indicate timeout error as it seems cleaner for this API. WaitEventSetWaitBlock returns -1 for timeout but WaitEventSetWait treats timeout as 0 (to represent 0 events indicating timeout). If there's an alternative, cleaner way to achieve this outcome, I am all ears. Thanks. -- Shawn Debnath Amazon Web Services (AWS)
Commits
-
Forward received condition variable signals on cancel.
- b91dd9de5ea0 13.0 landed
-
Introduce timed waits for condition variables.
- 1321509fa432 13.0 landed