Skip to content

Commit

Permalink
review suggestions: better proto name and code comments
Browse files Browse the repository at this point in the history
Signed-off-by: Florent Poinsard <[email protected]>
  • Loading branch information
frouioui committed Feb 20, 2025
1 parent c7ad375 commit 812df8f
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 221 deletions.
413 changes: 206 additions & 207 deletions go/vt/proto/vtgate/vtgate.pb.go

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions go/vt/proto/vtgate/vtgate_vtproto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions go/vt/vterrors/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func (o *VitessError) Cause() error {

var _ error = (*VitessError)(nil)

// errorWithoutState is an error that does not have any state, e.g. the state will be unknown
func errorWithoutState(id string, code vtrpcpb.Code, short, long string) func(args ...any) *VitessError {
return func(args ...any) *VitessError {
s := short
Expand Down Expand Up @@ -268,6 +269,8 @@ func errorWithState(id string, code vtrpcpb.Code, state State, short, long strin
}
}

// errorWithNoCode creates a VitessError where the error code is set by the user when creating the error
// instead of having a static error code that is declared in this file.
func errorWithNoCode(id string, short, long string) func(code vtrpcpb.Code, args ...any) *VitessError {
return func(code vtrpcpb.Code, args ...any) *VitessError {
s := short
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtgate/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func (e *Executor) handleRollback(ctx context.Context, safeSession *econtext.Saf
e.updateQueryCounts("Rollback", "", "", int64(logStats.ShardQueries))
err := e.txConn.Rollback(ctx, safeSession)
logStats.CommitTime = time.Since(execStart)
safeSession.SetTxErrorBlockNextQueries(false) // We have executed a ROLLBACK, if applicable: we can stop blocking queries on this session
safeSession.SetErrorUntilRollback(false) // We have executed a ROLLBACK, if applicable: we can stop blocking queries on this session
return &sqltypes.Result{}, err
}

Expand Down
8 changes: 4 additions & 4 deletions go/vt/vtgate/executorcontext/safe_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,16 @@ func (session *SafeSession) GetCommitOrder() vtgatepb.CommitOrder {
return session.commitOrder
}

func (session *SafeSession) SetTxErrorBlockNextQueries(enable bool) {
func (session *SafeSession) SetErrorUntilRollback(enable bool) {
session.mu.Lock()
defer session.mu.Unlock()
session.TxErrorBlockNextQueries = enable
session.ErrorUntilRollback = enable
}

func (session *SafeSession) GetTxErrorBlockNextQueries() bool {
func (session *SafeSession) IsErrorUntilRollback() bool {
session.mu.Lock()
defer session.mu.Unlock()
return session.Session.GetTxErrorBlockNextQueries()
return session.Session.GetErrorUntilRollback()
}

// GetLogger returns executor logger.
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/plan_execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (e *Executor) newExecute(
defer cancel()

// If we have previously issued a VT15001 error, we block every queries on this session until we receive a ROLLBACK.
if plan.Type != sqlparser.StmtRollback && safeSession.GetTxErrorBlockNextQueries() {
if plan.Type != sqlparser.StmtRollback && safeSession.IsErrorUntilRollback() {
return vterrors.VT15002()
}

Expand Down Expand Up @@ -369,7 +369,7 @@ func (e *Executor) rollbackOnFatalTxError(ctx context.Context, safeSession *econ
}
// we already know one or more shards are going to fail rolling back, the error can be discarded
_ = e.txConn.Rollback(ctx, safeSession)
safeSession.SetTxErrorBlockNextQueries(true)
safeSession.SetErrorUntilRollback(true)
return true
}

Expand Down
2 changes: 1 addition & 1 deletion proto/vtgate.proto
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ message Session {
// MigrationContext
string migration_context = 27;

bool tx_error_block_next_queries = 28;
bool error_until_rollback = 28;
}

// PrepareData keeps the prepared statement and other information related for execution of it.
Expand Down

0 comments on commit 812df8f

Please sign in to comment.