You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mark schema template replacements as Stable to enable Replacer cache (#1242)
* Mark schema template replacements as Stable to enable Replacer cache
schemaTemplateParam (and the schema replacement in ColumnExists) never
set Stable: true, so the sqlctemplate.Replacer cache introduced in #802
is bypassed on every query. This causes regexp.ReplaceAllStringFunc to
run on every SQL query, allocating a new string each time.
Under production throughput this creates enough allocation pressure to
cause visible memory growth — we observed +29MB in 16 minutes on a
worker running river.Start() with continuous job polling.
The schema value comes from the client config and is constant for the
lifetime of a River client, so marking it Stable is safe. With this
change, the regex runs once per unique SQL string and then serves from
cache.
Fixes all three drivers: riverpgxv5, riverdatabasesql, riversqlite.
Fixes#1241
* Add entry to changelog
* revert Stable: true in ColumExists in river_pgx_v5_driver
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
10
10
### Fixed
11
11
12
+
- Mark schema replacements as `Stable` in sqlc templates, preventing query SQL from having to be reallocated over and over again.. [PR #1242](https://github.com/riverqueue/river/pull/1242).
- Fix bug in `sqltemplate` cached path in order in which named args are passed to a query (previously, the order was unstable). [PR #1243](https://github.com/riverqueue/river/pull/1243).
0 commit comments