do not use prepared statements for mutations, close #2012 #5255
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.
This PR introduces changes that should reduce memory consumption (which could result in a leak) on both graphql-engine and Postgres for a mutation heavy workload.
Description
With mutations we end up with several 'single-use' prepared SQL statements, i.e, statements which cannot be reused for multiple mutations. The underlying reason for ending up with 'single-use' prepared statements is we embed values inside the statement instead of parameterizing them to reduce the complexity around handling relationships in
returningclause. The problem with single-use prepared statements is that we end up leaking memory both on graphql-engine (we store a mapping of "SQL prepared statement" to "postgres's prepared statement id" in eachPGConn) and on Postgres (no limits on number of prepared statements per connection).Changelog
CHANGELOG.mdis updated with user-facing content relevant to this PR. If no changelog is required, then add theno-changelog-requiredlabel.Affected components
Related Issues
#2012
#3388
#4077
Solution and Design
Prepared statements are not used for mutations any more. We might potentially end up with slightly slower but the benefit of predictable memory usage outweighs the potential degradation.
Steps to test and verify
@tirumaraiselvan has been running some benchmarks with a mutation heavy workload. This PR will be updated with the findings from those benchmarks.
Does this PR add a new Metadata feature?
GraphQL
Breaking changes