Skip to content

Ignore already commited transaction during connector metrics collection#29169

Merged
findepi merged 3 commits intotrinodb:masterfrom
starburstdata:ls/2604/02-tx-already-commited
Apr 20, 2026
Merged

Ignore already commited transaction during connector metrics collection#29169
findepi merged 3 commits intotrinodb:masterfrom
starburstdata:ls/2604/02-tx-already-commited

Conversation

@lukasz-stec
Copy link
Copy Markdown
Member

Description

The connector metrics collection can fail if the
transaction was committed after the check to see if the transaction is active. This is expected, and we should not log an error in this case.

Avoids logs like

2026-04-17T11:39:14.300Z        ERROR   dispatcher-query-3      io.trino.execution.QueryStateMachine    Error collecting query catalog metadata metrics: 20260417_113913_00033_3bybf
java.lang.IllegalStateException: Current transaction already committed
        at io.trino.transaction.InMemoryTransactionManager$TransactionMetadata.checkOpenTransaction(InMemoryTransactionManager.java:387)
        at io.trino.transaction.InMemoryTransactionManager$TransactionMetadata.getTransactionCatalogMetadata(InMemoryTransactionManager.java:434)
        at java.base/java.util.Optional.map(Optional.java:260)
        at io.trino.transaction.InMemoryTransactionManager.getOptionalCatalogMetadata(InMemoryTransactionManager.java:202)
        at io.trino.transaction.TransactionManager.getRequiredCatalogMetadata(TransactionManager.java:54)
        at io.trino.metadata.MetadataManager.getMetrics(MetadataManager.java:495)
        at io.trino.tracing.TracingMetadata.getMetrics(TracingMetadata.java:308)
        at io.trino.execution.QueryStateMachine.collectCatalogMetadataMetrics(QueryStateMachine.java:421)
        at io.trino.execution.QueryStateMachine.getQueryStats(QueryStateMachine.java:941)
        at io.trino.execution.QueryStateMachine.getQueryInfo(QueryStateMachine.java:695)
        at io.trino.execution.QueryStateMachine.updateQueryInfo(QueryStateMachine.java:1486)
        at io.trino.execution.scheduler.StageManager.lambda$initialize$0(StageManager.java:167)
        at io.trino.execution.StageStateMachine.lambda$addFinalStageInfoListener$0(StageStateMachine.java:220)
        at io.trino.execution.StateMachine.fireStateChangedListener(StateMachine.java:240)
        at io.trino.execution.StateMachine.lambda$fireStateChanged$0(StateMachine.java:232)
        at io.airlift.concurrent.BoundedExecutor.drainQueue(BoundedExecutor.java:79)
        at io.trino.$gen.Trino_testversion____20260417_113846_1.run(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1090)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:614)
        at java.base/java.lang.Thread.run(Thread.java:1474)

Additional context and related issues

Release notes

( X) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

The connector metrics collection can fail if the
transaction was committed after the check to see if the transaction is active. This is expected, and we should not log an error in this case.
@cla-bot cla-bot Bot added the cla-signed label Apr 20, 2026
@lukasz-stec lukasz-stec requested a review from findepi April 20, 2026 08:11
@findepi findepi requested review from losipiuk and p3tr0sz April 20, 2026 08:40
Copy link
Copy Markdown
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

The connector metrics collection can fail if the transaction was committed

This means that connector metrics collection is racing with query finish.
It might be unavoidable, but maybe it's not.

Was there any prior discussion on the topic?

@lukasz-stec
Copy link
Copy Markdown
Member Author

The connector metrics collection can fail if the transaction was committed

This means that connector metrics collection is racing with query finish. It might be unavoidable, but maybe it's not.

Was there any prior discussion on the topic?

There was some discussion in #26900. Mostly with you. From what I remember, the race is there because of the collection of final query info, and query finish is not synchronized (in general, not in the Java way).

@findepi findepi changed the title Ignore already commited transaction Ignore already commited transaction during connector metrics collection Apr 20, 2026
@findepi findepi added the no-release-notes This pull request does not require release notes entry label Apr 20, 2026
@findepi findepi merged commit 95c08d4 into trinodb:master Apr 20, 2026
100 checks passed
@findepi findepi deleted the ls/2604/02-tx-already-commited branch April 20, 2026 18:37
@github-actions github-actions Bot added this to the 481 milestone Apr 20, 2026
@ebyhr ebyhr mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed no-release-notes This pull request does not require release notes entry

Development

Successfully merging this pull request may close these issues.

3 participants