-
Notifications
You must be signed in to change notification settings - Fork 4.1k
sql: ensure the home region savepoint is not broken by pausable portals #99408
Copy link
Copy link
Open
Labels
A-pausable-portalsIssues related to multiple active portalsIssues related to multiple active portalsC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Description
When re-executing a pausable portal, we re-call the connExecutor.execStmtInOpenState(). Originally, the logic in this function is expected to be run only once for each query, so we're not sure if they should be rerun for a portal. This home region savepoint part is an example, and we should confirm its usage.
cockroach/pkg/sql/conn_executor_exec.go
Lines 739 to 768 in d8ea15c
| if enforceHomeRegion && ex.state.mu.txn.IsOpen() && isSelectStmt { | |
| // Create a savepoint at a point before which rows were read so that we can | |
| // roll back to it, which will allow the txn to be modified with a | |
| // historical timestamp (so that the locality-optimized ops used for error | |
| // reporting can run locally and not incur latency). This is currently only | |
| // supported for SELECT statements. | |
| var b strings.Builder | |
| b.WriteString("enforce_home_region_sp") | |
| // Add some unprintable ASCII characters to the name of the savepoint to | |
| // decrease the likelihood of collision with a user-created savepoint. | |
| b.WriteRune(rune(0x11)) | |
| b.WriteRune(rune(0x12)) | |
| b.WriteRune(rune(0x13)) | |
| enforceHomeRegionSavepointName := tree.Name(b.String()) | |
| s := &tree.Savepoint{Name: enforceHomeRegionSavepointName} | |
| var event fsm.Event | |
| var eventPayload fsm.EventPayload | |
| if event, eventPayload, err = ex.execSavepointInOpenState(ctx, s, res); err != nil { | |
| return event, eventPayload, err | |
| } | |
| r = &tree.ReleaseSavepoint{Savepoint: enforceHomeRegionSavepointName} | |
| rollbackSP = &tree.RollbackToSavepoint{Savepoint: enforceHomeRegionSavepointName} | |
| defer func() { | |
| // The default case is to roll back the internally-generated savepoint | |
| // after every request. We only need it if a retryable "query has no home | |
| // region" error occurs. | |
| ex.execRelease(ctx, r, res) | |
| }() | |
| } |
Jira issue: CRDB-25869
Epic CRDB-25183
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-pausable-portalsIssues related to multiple active portalsIssues related to multiple active portalsC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries TeamSQL Queries Team
Type
Projects
Status
Backlog