Repository navigation
fix(lakebase): recycle pool connections and pass through dropped pool options - #744
Draft
calvarjorge wants to merge 7 commits into
Draft
calvarjorge wants to merge 7 commits into
calvarjorge wants to merge 7 commits into
Conversation
… options getLakebasePgConfig() built the pg.Pool config from a fixed list of 11 keys, so maxLifetimeSeconds, application_name, keepAlive, query_timeout and options were silently dropped. Without a lifetime, pool connections were never recycled. Access granted through Unity Catalog claims in a Lakebase OAuth token stops working 4 hours after the token is minted while the connection stays open, so a busy pool kept failing with "permission denied" until the app restarted. - Pass the five options through to pg.Pool, keeping the explicit key list. - Default maxLifetimeSeconds to 1800 (30 minutes); an explicit 0 is kept. - Warn when maxLifetimeSeconds is 0 or above 9000 (2.5 hours): the 4-hour lapse, less up to an hour of token age at login, less a 30-minute margin. - Ignore a negative or non-finite maxLifetimeSeconds, with a warning, and use the default. pg-pool would otherwise close every connection as soon as it opens (negative) or never recycle (NaN). - Document maxLifetimeSeconds, including that held clients are only recycled on release, and regenerate the API docs. - Add unit tests for the default, the warnings and the pass-through. - Add tools/lakebase-soak.ts, a soak harness that runs a real pool against a sandbox endpoint and checks connection age, token age at login, application_name and table access. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Bill McMillin <bill.mcmillin@databricks.com>
pg-pool passes maxLifetimeSeconds * 1000 to setTimeout. Above 2^31 - 1 ms (about 24.8 days), Node fires the timer after 1 ms, so every connection closed after a single use. Treat those values like Infinity: warn and use the default. Compare in milliseconds so 2147483 s is kept and fractional values just past the limit are rejected. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Bill McMillin <bill.mcmillin@databricks.com>
The soak harness recorded a Ctrl-C stop as `incomplete` but left it out of `passed`, so a run stopped after the one-hour token boundary still passed and exited 0. Add a `ran_full_duration` check so a stopped run always fails and the summary shows why. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Bill McMillin <bill.mcmillin@databricks.com>
Contributor
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh run download 45199193883 -R databricks/appkit -n appkit-template-0.102.0-pr.1cb7716-fix-lakebase-connection-lifetime-744 -D appkit-pr-744 \
&& unzip -o "appkit-pr-744/appkit-template-0.102.0-pr.1cb7716-fix-lakebase-connection-lifetime-744.zip" -d "appkit-pr-744" \
&& databricks apps init --template "appkit-pr-744"The template pins |
`connections_recycled` only checked that no pool connection outlived the lifetime, so a run shorter than the lifetime passed without seeing any connection recycled. Also require the oldest connection to reach the lifetime, less one interval and the probe slack. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Bill McMillin <bill.mcmillin@databricks.com>
… exec Under `pnpm exec tsx`, one Ctrl-C reaches the harness as a SIGINT from the terminal, a SIGTERM from pnpm 1 ms later and a SIGINT relayed by tsx 30 ms after that. The harness had no SIGTERM handler, so pnpm's SIGTERM killed it before it wrote a summary, and `ran_full_duration` never ran. Treat SIGTERM like SIGINT, and signals within a second of the first as the same stop request; only a later signal quits immediately. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: Bill McMillin <bill.mcmillin@databricks.com>
This branch has not been deployed
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.
Important
CI validation only - do not review or merge. This is a repush of #719 (from a fork), kept at its current head, to run CI with repo secrets: fork runs can't get the OIDC token
setup-jfrog-npmneeds. Review and merge happen on #719. This PR will be closed once CI finishes.This pull request and its description were written by Isaac.