-
Notifications
You must be signed in to change notification settings - Fork 73
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
Interrupt handling #26
Conversation
mkaruza
commented
May 8, 2024
- Declare QuackNode to HOLD_INTERRUPTS for duration of scan. Once interrupt is observed we exit execution after heap pages are closed.
583f4b4
to
9675c1c
Compare
Note that most postgres internal functions can ereport an error for a wide range of reasons, so the code needs to be prepared for that anyway regardless of interrupts. |
@hlinnaka You are by right looking at PG code. This interrupt PR is mostly for safer cleaning and closing all pages during query execution. You think that this should be checking specific - |
When custom scan node start we are increasing `QueryCancelHoldoffCount` to block canceling query. In fetch page loop we are monitoring `QueryCancelPending` signal for thread to finish execution. `QueryCancelHoldoffCount` counter will be decreased when node exits.
9675c1c
to
bf55f86
Compare
We can call We could launch a background thread that polls periodically whether or not a cancellation has happened, when it has happened we call Interrupt. |
@@ -47,14 +47,14 @@ void | |||
Quack_BeginCustomScan(CustomScanState *cscanstate, EState *estate, int eflags) { | |||
QuackScanState *quackScanState = (QuackScanState *)cscanstate; | |||
quackScanState->css.ss.ps.ps_ResultTupleDesc = quackScanState->css.ss.ss_ScanTupleSlot->tts_tupleDescriptor; | |||
HOLD_CANCEL_INTERRUPTS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could in the future e.g. have a background thread here:
void CheckForInterrupts() {
while(!finished) {
if (QueryCancelPending) {
connection->Interrupt();
break;
}
sleep(10ms);
}
}