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

Prevent recursion in invalidation processing #1493

Merged
merged 1 commit into from Oct 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 18 additions & 4 deletions src/extension.c
Expand Up @@ -198,6 +198,18 @@ 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 All @@ -207,7 +219,7 @@ ts_extension_invalidate(Oid relid)
case EXTENSION_STATE_TRANSITIONING:
/* Has the create/drop extension finished? */
extension_update_state();
return false;
break;
case EXTENSION_STATE_CREATED:

/*
Expand All @@ -224,14 +236,16 @@ ts_extension_invalidate(Oid relid)
* note this state may be UNKNOWN but should be
* conservative
*/
return true;
invalidate_all = true;
}
}
return false;
break;
default:
elog(ERROR, "unknown state: %d", extstate);
return false;
break;
}
in_recursion = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is in_recursion being reset here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this recursive only if extension_update_state recursively calls the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

return invalidate_all;
}

bool
Expand Down