Skip to content

Commit 5cfde24

Browse files
NJrslvtuhaihe
authored andcommitted
[gp_stats_collector] Wrap hook call in try/catch on error path
Add PG_TRY/PG_CATCH around query_info_collect_hook in PortalCleanup error path to prevent exceptions from propagating during cleanup.
1 parent 3a8cc5c commit 5cfde24

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/backend/commands/portalcmds.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,22 @@ PortalCleanup(Portal portal)
374374
FreeQueryDesc(queryDesc);
375375

376376
CurrentResourceOwner = saveResourceOwner;
377-
} else {
377+
}
378+
else
379+
{
378380
/* GPDB hook for collecting query info */
379381
if (queryDesc->gpsc_query_key && query_info_collect_hook)
380-
(*query_info_collect_hook)(METRICS_QUERY_ERROR, queryDesc);
382+
{
383+
PG_TRY();
384+
{
385+
(*query_info_collect_hook)(METRICS_QUERY_ERROR, queryDesc);
386+
}
387+
PG_CATCH();
388+
{
389+
FlushErrorState();
390+
}
391+
PG_END_TRY();
392+
}
381393
}
382394
}
383395

0 commit comments

Comments
 (0)