Repository navigation
fix(fork): backport k3s-io/kine#795 Migrate connection leak fix - #38
Merged
cbalan merged 1 commit intoNov 12, 2026
Merged
Conversation
cbalan
force-pushed
the
fix/engcp-1950-migrate-leak-v0.17.2
branch
from
November 9, 2026 16:30
4c3503f to
6194e8b
Compare
cbalan
force-pushed
the
fix/engcp-1950-migrate-leak-v0.17.2
branch
from
November 9, 2026 16:34
6194e8b to
09a35c8
Compare
cbalan
force-pushed
the
fix/engcp-1950-migrate-leak-v0.17.2
branch
from
November 10, 2026 15:57
09a35c8 to
a21327e
Compare
Piotr1215
approved these changes
Nov 12, 2026
Piotr1215
left a comment
There was a problem hiding this comment.
LGTM. Verified the upstream patch and the regression test with cgo and nocgo.
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.
Backport of upstream k3s-io#795 (commit k3s-io/kine@f805442, "Fix connection leak in Migrate") to the v0.17.2 release line, as a
fix(fork)commit per the fork policy. The upstream patch applies cleanly here.Replay note: upstream v0.17.3 and later already contain this fix and then remove
Migratealtogether ("Drop migration support", same upstream PR). Drop this commit when replaying the fork commits onto a release line cut from v0.17.3 or later; it conflicts inpkg/drivers/generic/generic.gothere.Why
On this branch
TestCompactfails on cgo SQLite: the post-compactionPRAGMA wal_checkpoint(FULL)waits out the full 30 s_busy_timeout, and the apiserver test cancels the Compact call. This is theTest sqlitefailure that #35 merged with.Root cause:
Generic.Migrateopened bothCOUNT(*)rows up front and returned after the firstScanfailed (nokey_valuetable), so the second row was never read and kept its connection checked out. With_stmt_cache_size=20inDefaultParams, go-sqlite3 steps the cached statement eagerly, so that leaked connection also holds a read transaction on the startup snapshot. FULL waits for every reader to reach the latest snapshot, so it blocks until the busy timeout.Pinning the
golang:1.26-alpine3.23digest would not fix this: the stall reproduces locally on Go 1.26.5, 1.26.8 and 1.26.10.Changes
pkg/drivers/generic/generic.go: querykineonly after thekey_valuerow has been scanned and warrants it.pkg/drivers/sqlite/sqlite_test.go: adds upstream'sTestMigrateReleasesItsConnections(1-connection pool, DB must stay usable afterMigrate).Testing
wal_checkpoint(FULL)): before the fix,busy=1after 3.1 s with 1 connection still in use; after,busy=0in about 0.25 ms. Same result for cgo (mattn, SQLite 3.53.4) and nocgo (modernc).TestMigrateReleasesItsConnectionspasses withCGO_ENABLED=1andCGO_ENABLED=0.CGO_ENABLED=1 go test ./pkg/drivers/... ./pkg/logstructured/...passes.TestCompactsuite was not run locally; the SQLite CI jobs on this PR cover it.Refs: ENGCP-1950
🤖 Generated with Claude Code