Skip to content

Commit 422711a

Browse files
committed
sql: fix dispatchReadCommittedStmtToExecutionEngine for pausable portals
If we want to preserve retry information then I think we need to save these fields in the pauseInfo. Informs: #145377 Release note: None
1 parent 39e8291 commit 422711a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pkg/sql/conn_executor_exec.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2722,6 +2722,17 @@ func (ex *connExecutor) rollbackSQLTransaction(
27222722
func (ex *connExecutor) dispatchReadCommittedStmtToExecutionEngine(
27232723
ctx context.Context, p *planner, res RestrictedCommandResult,
27242724
) error {
2725+
getPausablePortalInfo := func() *portalPauseInfo {
2726+
if p != nil && p.pausablePortal != nil {
2727+
return p.pausablePortal.pauseInfo
2728+
}
2729+
return nil
2730+
}
2731+
if ppInfo := getPausablePortalInfo(); ppInfo != nil {
2732+
p.autoRetryStmtReason = ppInfo.dispatchReadCommittedStmtToExecutionEngine.autoRetryStmtReason
2733+
p.autoRetryStmtCounter = ppInfo.dispatchReadCommittedStmtToExecutionEngine.autoRetryStmtCounter
2734+
}
2735+
27252736
readCommittedSavePointToken, err := ex.state.mu.txn.CreateSavepoint(ctx)
27262737
if err != nil {
27272738
return err
@@ -2796,6 +2807,10 @@ func (ex *connExecutor) dispatchReadCommittedStmtToExecutionEngine(
27962807
}
27972808
p.autoRetryStmtCounter++
27982809
p.autoRetryStmtReason = maybeRetriableErr
2810+
if ppInfo := getPausablePortalInfo(); ppInfo != nil {
2811+
ppInfo.dispatchReadCommittedStmtToExecutionEngine.autoRetryStmtReason = p.autoRetryStmtReason
2812+
ppInfo.dispatchReadCommittedStmtToExecutionEngine.autoRetryStmtCounter = p.autoRetryStmtCounter
2813+
}
27992814
}
28002815
return nil
28012816
}

pkg/sql/prepared_stmt.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,15 @@ type portalPauseInfo struct {
259259
cleanup cleanupFuncStack
260260
}
261261

262+
dispatchReadCommittedStmtToExecutionEngine struct {
263+
// autoRetryStmtReason is the planner.autoRetryStmtReason to restore when
264+
// resuming a portal.
265+
autoRetryStmtReason error
266+
// autoRetryStmtCounter is the planner.autoRetryStmtCounter to restore when
267+
// resuming a portal.
268+
autoRetryStmtCounter int
269+
}
270+
262271
// TODO(sql-session): replace certain fields here with planner.
263272
// https://github.com/cockroachdb/cockroach/issues/99625
264273
dispatchToExecutionEngine struct {

0 commit comments

Comments
 (0)