Skip to content

PG write query timeouts - #321

Merged
suddendust merged 1 commit into
mainfrom
pg_write_query_timeout
Aug 13, 2026
Merged

PG write query timeouts#321
suddendust merged 1 commit into
mainfrom
pg_write_query_timeout

Conversation

@suddendust

Copy link
Copy Markdown
Contributor

Description

This PR sets query timeout for write APIs in FlatPostgresCollection.

Testing

Added an integration test

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.44444% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 81.06%. Comparing base (c534f39) to head (128b206).

Files with missing lines Patch % Lines
...documentstore/postgres/FlatPostgresCollection.java 92.85% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #321      +/-   ##
============================================
+ Coverage     81.04%   81.06%   +0.01%     
- Complexity     1615     1617       +2     
============================================
  Files           243      243              
  Lines          7650     7656       +6     
  Branches        754      755       +1     
============================================
+ Hits           6200     6206       +6     
  Misses          960      960              
  Partials        490      490              
Flag Coverage Δ
integration 81.06% <94.44%> (+0.01%) ⬆️
unit 57.15% <66.66%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Test Results

  125 files  +1    125 suites  +1   38s ⏱️ -1s
  855 tests +3    854 ✅ +3  1 💤 ±0  0 ❌ ±0 
1 192 runs  +3  1 191 ✅ +3  1 💤 ±0  0 ❌ ±0 

Results for commit 128b206. ± Comparison against base commit c534f39.

if (queryTimeoutSeconds > 0) {
preparedStatement.setQueryTimeout(queryTimeoutSeconds);
}
return preparedStatement;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this set per prepared statement? or is it possible to set it at connection?

@suddendust suddendust Aug 13, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it's a bit nuanced. There're three ways to do this:

  1. Set it in PS - Like what we're doing here. In this case, the driver cancels the query by sending a new cancel request to the server.
  2. Set it at a connection level - By setting SET statement_timeout = 60s in the connection pool config. However, this might pin connections at the proxy (using SET commands does but the doc is not very clear on whether SET statement_timeout will do this).
  3. Set it in the RDS parameter group. This applies this timeout to any client regardless of what they've configured. Client can still use setQueryTimeout to set a value lesser than the global value in the param group.

Given our issues with pinning, I'll go with 1 + 3.

@suddendust
suddendust merged commit 330cbc2 into main Aug 13, 2026
7 checks passed
@suddendust
suddendust deleted the pg_write_query_timeout branch August 13, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants