Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: ensure the home region savepoint is not broken by pausable portals #99408

Open
ZhouXing19 opened this issue Mar 23, 2023 · 0 comments
Open
Labels
A-pausable-portals Issues related to multiple active portals C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@ZhouXing19
Copy link
Collaborator

ZhouXing19 commented Mar 23, 2023

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.

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

@ZhouXing19 ZhouXing19 added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) A-pausable-portals Issues related to multiple active portals labels Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-pausable-portals Issues related to multiple active portals C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

No branches or pull requests

1 participant