Skip to content

Conversation

@NikolayS
Copy link

@NikolayS NikolayS commented Dec 4, 2025

Reduces metric queries from 4 roundtrips (BEGIN/SET/query/COMMIT) to 1 by setting lock_timeout at connection level via pgx RuntimeParams.

  • Add --conn-lock-timeout option (default: 100ms, env: PW_CONN_LOCK_TIMEOUT)
  • Set lock_timeout in RuntimeParams for PostgreSQL sources on connect
  • Simplify QueryMeasurements by removing transaction wrapper
  • Set to "0" to disable lock_timeout

Ref: https://brandur.org/fragments/postgres-parameters

@pashagolub pashagolub self-assigned this Dec 4, 2025
@pashagolub pashagolub added metrics Metrics related issues refactoring Something done as it should've been done from the start labels Dec 4, 2025
…y transaction

Reduces metric queries from 4 roundtrips (BEGIN/SET/query/COMMIT) to 1 by
setting lock_timeout at connection level via pgx RuntimeParams.

- Add --conn-lock-timeout option (default: 100ms, env: PW_CONN_LOCK_TIMEOUT)
- Set lock_timeout in RuntimeParams for PostgreSQL sources on connect
- Simplify QueryMeasurements by removing transaction wrapper
- Set to "0" to disable lock_timeout

Ref: https://brandur.org/fragments/postgres-parameters
@pashagolub pashagolub force-pushed the claude/postgres-lock-timeout-config-01CV6RHcoPstQMGhREGnNE8r branch from 03456f7 to 2fe21ee Compare December 4, 2025 13:31
@pashagolub
Copy link
Collaborator

Thanks! Can you ask Claude to fix tests or should I? :-)

Tests no longer expect transaction wrapping (BEGIN/SET/COMMIT) since
lock_timeout is now set via RuntimeParams at connection time.
@NikolayS
Copy link
Author

NikolayS commented Dec 4, 2025

Thanks! Can you ask Claude to fix tests or should I? :-)

@pashagolub attempted in 56d368f

@coveralls
Copy link

Pull Request Test Coverage Report for Build 19946747772

Details

  • 3 of 5 (60.0%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.009%) to 73.606%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/sources/conn.go 1 3 33.33%
Files with Coverage Reduction New Missed Lines %
internal/reaper/database.go 1 76.66%
Totals Coverage Status
Change from base Build 19930713686: -0.009%
Covered Lines: 3684
Relevant Lines: 5005

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metrics Metrics related issues refactoring Something done as it should've been done from the start

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants