Repository navigation
Finalize SQLite statements at query scope exit - #86
Merged
Merged
Conversation
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.
Generated SQLite queries prepare a new statement for each execution, but only reset it afterward. The statements and their bound values remain allocated, causing native memory to grow on long-running connections and preventing those connections from closing cleanly.
Finalize each statement with nonraising deferred cleanup immediately after preparation. Cleanup runs on normal completion, binding and result-conversion failures, exceptions, and iterator break or early return. Scope query expressions locally and remove the unused statement preparation outside generated routines, while preserving execution-error reporting.
Server profiling showed live native heap growing to 2.64 GiB after 7,019 ingested records. A focused statement-cleanup experiment stayed around 26 MiB through 10,000 records. A full 10,000-record server run with the final fix peaked at 25.22 MiB and ended at 24.17 MiB, including slow or unavailable downstream services, recovery, and two idle minutes.
Add regression tests for repeated queries followed by connection closure, typed queries, generated procedures and iterators, unused routine declarations, constraint errors, and exceptional exits. SQLite and PostgreSQL suites pass in CI.
CI installs Atlas through its official
install.shscript and runs the test suites through Atlas. Example builds also pass with Jester >=0.6.0, which avoids the removed stdlibscgidependency in older releases.