Rollbacks on exit during successful online GC worker runs are triggering alerts on Patroni
Problem
Right now, when a worker executes it starts by creating a transaction and checking if a task exists. If a task does not exist it will simply exit and during the exit a default wrapping function will execute a rollback on that transaction. The purpose of this wrapping function is to ensure that no transaction will be left "running" without a final commit/rollback (e.g. if a panic occurs or we forgot to call commit/rollback explicitly in any place as we should do), but there is currently no check on whether a rollback is actually needed or not, so it's erring on the excessive side.
While this does not cause any functional problem, executing a rollback count towards a Patroni metric to detect possible problems, and this is currently triggering an alert in production.
Solution
Ideally, we should only execute a rollback if an error occurred. The online GC worker code must be changed taking this into account.