Skip to content

Commit

Permalink
Merge #49221 #49224
Browse files Browse the repository at this point in the history
49221: sql: deal with retriable errors in `DROP INDEX` r=spaskob,lucy-zhang a=ajwerner

Prior to this commit we would assume any error while retrieving a descriptor
during the execution of `DROP INDEX` was an assertion failure. This was
overly paranoid. Plenty of retriable errors are possible (and furthermore
so are errors due to shutdown). The only error we should freak out about
is if we discover the relation is not defined.

Fixes #48474.

Release note (bug fix): Fix bug where contended `DROP INDEX` queries return
an assertion failure error rather than a retriable error.

49224: kv: include lease epoch in RangeInfo.CTEntry r=nvanbenschoten a=nvanbenschoten

Should help with debugging.

Co-authored-by: Andrew Werner <[email protected]>
Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
3 people committed May 19, 2020
3 parents 41e568c + 1d421da + 3c0de0f commit 2235a75
Show file tree
Hide file tree
Showing 7 changed files with 247 additions and 70 deletions.
3 changes: 2 additions & 1 deletion pkg/kv/kvserver/replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -1025,8 +1025,9 @@ func (r *Replica) State() storagepb.RangeInfo {
}
if ri.NewestClosedTimestamp.ClosedTimestamp.Less(e.ClosedTimestamp) {
ri.NewestClosedTimestamp.NodeID = replDesc.NodeID
ri.NewestClosedTimestamp.MLAI = int64(mlai)
ri.NewestClosedTimestamp.ClosedTimestamp = e.ClosedTimestamp
ri.NewestClosedTimestamp.MLAI = int64(mlai)
ri.NewestClosedTimestamp.Epoch = int64(e.Epoch)
}
return true // done
})
Expand Down
165 changes: 98 additions & 67 deletions pkg/kv/kvserver/storagepb/state.pb.go

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

1 change: 1 addition & 0 deletions pkg/kv/kvserver/storagepb/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ message RangeInfo {
(gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/roachpb.NodeID"];
util.hlc.Timestamp closed_timestamp = 2 [(gogoproto.nullable) = false];
int64 mlai = 3 [(gogoproto.customname) = "MLAI"];
int64 epoch = 4;
}
// The highest closed timestamp known to have data for this replica, taken
// across the data received from all nodes. This does not reflect whether
Expand Down
5 changes: 4 additions & 1 deletion pkg/sql/drop_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,16 @@ func (n *dropIndexNode) startExec(params runParams) error {
// drop need to be visible to the second drop.
tableDesc, err := params.p.ResolveMutableTableDescriptor(
ctx, index.tn, true /*required*/, ResolveRequireTableDesc)
if err != nil {
if sqlbase.IsUndefinedRelationError(err) {
// Somehow the descriptor we had during planning is not there
// any more.
return errors.NewAssertionErrorWithWrappedErrf(err,
"table descriptor for %q became unavailable within same txn",
tree.ErrString(index.tn))
}
if err != nil {
return err
}

// If we couldn't find the index by name, this is either a legitimate error or
// this statement contains an 'IF EXISTS' qualifier. Both of these cases are
Expand Down
Loading

0 comments on commit 2235a75

Please sign in to comment.