Skip to content
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

Fix recursion in cache processing #2259

Merged
merged 1 commit into from
Aug 26, 2020
Merged
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
25 changes: 12 additions & 13 deletions src/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,20 @@ extension_set_state(enum ExtensionState newstate)
}

/* Updates the state based on the current state, returning whether there had been a change. */
static bool
static void
extension_update_state()
{
return extension_set_state(extension_current_state());
static bool in_recursion = false;
/* Since the state of the extension is determined by the snapshot of the transaction there
* is no point processing recursive calls as the outer call will always set the correct state.
* This also prevents deep recursion during `AcceptInvalidationMessages`.
*/
if (in_recursion)
return;

in_recursion = true;
extension_set_state(extension_current_state());
in_recursion = false;
}

Oid
Expand Down Expand Up @@ -199,18 +209,8 @@ ts_extension_schema_name(void)
bool
ts_extension_invalidate(Oid relid)
{
static bool in_recursion = false;
bool invalidate_all = false;

/* Since the state of the extension is determined by the snapshot of the transaction there
* is no point processing recursive calls as the outer call will always set the correct state.
* This also prevents deep recursion during `AcceptInvalidationMessages`.
*/
if (in_recursion)
return false;

in_recursion = true;

switch (extstate)
{
case EXTENSION_STATE_NOT_INSTALLED:
Expand Down Expand Up @@ -245,7 +245,6 @@ ts_extension_invalidate(Oid relid)
elog(ERROR, "unknown state: %d", extstate);
break;
}
in_recursion = false;
return invalidate_all;
}

Expand Down