Skip to content

Encode duration as bigint for pgx simple protocol#10529

Merged
simvlad merged 3 commits into
temporalio:mainfrom
simvlad:check-visibility-simple-protocol
Jun 5, 2026
Merged

Encode duration as bigint for pgx simple protocol#10529
simvlad merged 3 commits into
temporalio:mainfrom
simvlad:check-visibility-simple-protocol

Conversation

@simvlad
Copy link
Copy Markdown
Contributor

@simvlad simvlad commented Jun 4, 2026

What changed?

Remap time.Duration to Postgres int8 (bigint) on pgx connections.

Why?

See #10514. By default pgx encodes time.Duration as an interval (e.g. 00:00:05). Currently, there is a single Duration column VisibilityRow execution_duration which is written as a BigInt. Under the simple query protocol (PgBouncer transaction pooling) the write is rejected with invalid input syntax for type bigint. int8 sends the underlying int64 nanosecond count instead.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

The time.Duration → int8 mapping is changed for pgx driver, so not scoped to simple protocol. This should be fine, as tests exercise it with existing asserts and new s.Equal(req.ExecutionDuration, resp.GetExecutionDuration().AsDuration())

@simvlad simvlad requested review from a team as code owners June 4, 2026 17:47
Copy link
Copy Markdown
Contributor

@rodrigozhou rodrigozhou left a comment

Choose a reason for hiding this comment

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

Can you pull the changes to the tests I made in #10524 here? It would run unit tests verifying that this works correctly.

Comment thread common/persistence/sql/sqlplugin/postgresql/driver/pgx.go
Comment thread common/persistence/tests/postgresql_test.go Outdated
@rodrigozhou rodrigozhou force-pushed the check-visibility-simple-protocol branch from 0e821c6 to 52ede9c Compare June 4, 2026 20:58
@simvlad simvlad enabled auto-merge (squash) June 4, 2026 21:30
@simvlad simvlad merged commit 3c7e505 into temporalio:main Jun 5, 2026
73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants