fix(demo): reconnect the streaming job on token expiry / dropped connection#50
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The continuous
stream_ticksjob failed with: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_inserthit 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
safe_insertcatchespsycopg.OperationalError, reconnects with a fresh token, and retries the batch.Demo-only change (no SQL/version impact). Deploys via the demo bundle.