Wrap TTL expiration in TRY/CATCH instead of allowing reaper to exit on error
@@ -253,10 +253,13 @@ ContinuousQueryReaperMain(void)
for (;;)
{
int deleted = 0;
+ bool error = false;
StartTransactionCommand();
SetCurrentStatementStartTimestamp();
+ PG_TRY();
+ {
ttl_rels = get_ttl_rels(&min_sleep);
foreach(lc, ttl_rels)
@@ -282,13 +285,28 @@ ContinuousQueryReaperMain(void)
set_last_expiration(relid, deleted);
}
}
+ }
+ PG_CATCH();
+ {
+ EmitErrorReport();
+ FlushErrorState();
+
+ error = true;
+
+ if (ActiveSnapshotSet())
+ PopActiveSnapshot();
+
+ AbortCurrentTransaction();
+ StartTransactionCommand();
+ }
+ PG_END_TRY();
CommitTransactionCommand();
/*
* If nothing was deleted on this run, we're done for now
*/
- if (!deleted)
+ if (error || !deleted)
break;
}
