Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/backend/cdb/endpoint/cdbendpointutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,3 +599,16 @@ enable_parallel_retrieve_cursor_check_timeout(void)
GP_PARALLEL_RETRIEVE_CURSOR_CHECK_PERIOD_MS);
}
}

/*
* Disable the timeout of parallel retrieve cursor check.
*
* Safe to call unconditionally; disable_timeout() is a no-op when the
* timeout is not active.
*/
void
disable_parallel_retrieve_cursor_check_timeout(void)
{
if (Gp_role == GP_ROLE_DISPATCH)
disable_timeout(GP_PARALLEL_RETRIEVE_CURSOR_CHECK_TIMEOUT, false);
}
16 changes: 14 additions & 2 deletions src/backend/commands/portalcmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ PortalCleanup(Portal portal)
}
}

/*
* If resource scheduling is enabled, release the resource lock.
/*
* If resource scheduling is enabled, release the resource lock.
*/
if (IsResQueueLockedForPortal(portal))
{
Expand All @@ -410,6 +410,18 @@ PortalCleanup(Portal portal)
{
BackoffBackendEntryExit();
}

/*
* If this was a PARALLEL RETRIEVE CURSOR and no others remain, stop
* the periodic check timer immediately rather than waiting for the
* next stray SIGALRM to find a zero count and quiet itself.
* queryDesc was set to NULL above, so the now-cleaned portal is no
* longer counted by GetNumOfParallelRetrieveCursors().
*/
if (PortalIsParallelRetrieveCursor(portal) &&
Gp_role == GP_ROLE_DISPATCH &&
GetNumOfParallelRetrieveCursors() == 0)
disable_parallel_retrieve_cursor_check_timeout();
}

/*
Expand Down
20 changes: 11 additions & 9 deletions src/backend/utils/init/postinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1894,20 +1894,22 @@ GpParallelRetrieveCursorCheckTimeoutHandler(void)

/* It calls cdbdisp_checkForCancel(), which doesn't raise error */
gp_check_parallel_retrieve_cursor_error();
int num = GetNumOfParallelRetrieveCursors();

/* Reset the alarm to check after a timeout */
if (num > 0)
{
elog(DEBUG1, "There are still %d parallel retrieve cursors alive", num);
enable_parallel_retrieve_cursor_check_timeout();
}
}
else
{
elog(DEBUG1, "DoingCommandRead is false, check parallel cursor timeout delay");
enable_parallel_retrieve_cursor_check_timeout();
}

/*
* Only re-arm the periodic check while parallel retrieve cursors are
* still alive. Re-arming unconditionally (the previous behavior) kept
* a SIGALRM firing every GP_PARALLEL_RETRIEVE_CURSOR_CHECK_PERIOD_MS
* for the rest of the backend's life, which interfered with unrelated
* code paths -- most visibly truncating fault-injection 'sleep'
* windows used by isolation2 tests.
*/
if (GetNumOfParallelRetrieveCursors() > 0)
enable_parallel_retrieve_cursor_check_timeout();
}

/*
Expand Down
1 change: 1 addition & 0 deletions src/include/cdb/cdbendpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ extern void AtAbort_EndpointExecState(void);
extern void allocEndpointExecState(void);
extern bool gp_check_parallel_retrieve_cursor_error(void);
extern void enable_parallel_retrieve_cursor_check_timeout(void);
extern void disable_parallel_retrieve_cursor_check_timeout(void);

/*
* Below functions should run on Endpoints(QE/Entry DB).
Expand Down
Loading