Commit 74c234f9 authored by Stan Hu's avatar Stan Hu

Fix Geo Log Cursor not restarting after pgbouncer dies

If pgbouncer dies, then the connection may get stuck in `PQsocket() can't get
socket descriptor` state. Wrap the query in a transaction to allow the
connection to return to the pool and recover. This also potentially prevents
idle-in-transaction cancellations.

Closes #5145
parent eb091439
---
title: Fix Geo Log Cursor not reconnecting after pgbouncer dies
merge_request: !4866
author:
type: fixed
...@@ -34,7 +34,11 @@ module Gitlab ...@@ -34,7 +34,11 @@ module Gitlab
end end
def run_once! def run_once!
LogCursor::Events.fetch_in_batches { |batch| handle_events(batch) } # Wrap this with the connection to make it possible to reconnect if
# PGbouncer dies: https://github.com/rails/rails/issues/29189
ActiveRecord::Base.connection_pool.with_connection do
LogCursor::Events.fetch_in_batches { |batch| handle_events(batch) }
end
end end
def handle_events(batch) def handle_events(batch)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment