Skip to content

fix(demo): reconnect the streaming job on token expiry / dropped connection#50

Merged
taran-dbx merged 1 commit into
mainfrom
fix/stream-reconnect
Jun 9, 2026
Merged

fix(demo): reconnect the streaming job on token expiry / dropped connection#50
taran-dbx merged 1 commit into
mainfrom
fix/stream-reconnect

Conversation

@taran-dbx

Copy link
Copy Markdown
Collaborator

Problem

The continuous stream_ticks job failed with:

OperationalError: consuming input failed: SSL connection has been closed unexpectedly

It opened a single connection and looped forever with no reconnect. The Lakebase OAuth token lasts ~1h, and Lakebase terminates the connection once that token lapses (also on autoscale scaling / network blips) — so the next batch_insert hit a dead socket and the job died. The old code comment even assumed "a single long-lived connection outlives the ~1h token," which isn't true here.

Fix

  • Proactive refresh: reconnect before the token expires (every 50 min).
  • Reconnect-on-drop: safe_insert catches psycopg.OperationalError, reconnects with a fresh token, and retries the batch.

Demo-only change (no SQL/version impact). Deploys via the demo bundle.

…ection

The continuous stream_ticks job held a single connection and looped forever
with no reconnect. Lakebase closes the connection when the ~1h OAuth token it
logged in with expires (and on autoscale scaling / network blips), so the next
insert hit a dead socket -> 'SSL connection has been closed unexpectedly' and
the job failed.

Refresh the connection proactively before the token expires (50 min) and
reconnect-and-retry with a fresh token on any dropped connection.
@taran-dbx taran-dbx merged commit 6804a28 into main Jun 9, 2026
9 checks passed
@taran-dbx taran-dbx deleted the fix/stream-reconnect branch June 9, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant