Skip to content

Commit

Permalink
Log extension state changes
Browse files Browse the repository at this point in the history
To debug issues with extension state not being correct we log extension
state changes on `DEBUG1` level.

See #1682
  • Loading branch information
mkindahl committed Jan 10, 2024
1 parent 9c75b03 commit 8d821aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions .unreleased/fix_6512
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #6512 Log extension state changes
22 changes: 15 additions & 7 deletions src/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ static enum ExtensionState extstate = EXTENSION_STATE_UNKNOWN;
*/
static Oid ts_extension_oid = InvalidOid;

static const char *extstate_str[] = {
[EXTENSION_STATE_UNKNOWN] = "unknown",
[EXTENSION_STATE_TRANSITIONING] = "transitioning",
[EXTENSION_STATE_CREATED] = "created",
[EXTENSION_STATE_NOT_INSTALLED] = "not installed",
};

static bool
extension_loader_present()
{
Expand Down Expand Up @@ -150,6 +157,10 @@ extension_set_state(enum ExtensionState newstate)
ts_catalog_reset();
break;
}
elog(DEBUG1,
"extension state changed: %s to %s",
extstate_str[extstate],
extstate_str[newstate]);
extstate = newstate;
return true;
}
Expand Down Expand Up @@ -261,6 +272,10 @@ ts_experimental_schema_name(void)
void
ts_extension_invalidate(void)
{
elog(DEBUG1,
"extension state invalidated: %s to %s",
extstate_str[extstate],
extstate_str[EXTENSION_STATE_UNKNOWN]);
extstate = EXTENSION_STATE_UNKNOWN;
extension_proxy_oid = InvalidOid;
}
Expand Down Expand Up @@ -335,13 +350,6 @@ ts_extension_is_proxy_table_relid(Oid relid)
}

#ifdef TS_DEBUG
static const char *extstate_str[] = {
[EXTENSION_STATE_UNKNOWN] = "unknown",
[EXTENSION_STATE_TRANSITIONING] = "transitioning",
[EXTENSION_STATE_CREATED] = "created",
[EXTENSION_STATE_NOT_INSTALLED] = "not installed",
};

TS_FUNCTION_INFO_V1(ts_extension_get_state);

Datum
Expand Down

0 comments on commit 8d821aa

Please sign in to comment.