From 8315fd5134390f744ad751d344cc32d79f80c95e Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Mon, 14 Oct 2019 14:23:11 -0400 Subject: [PATCH 1/2] storage: Deflake TestReplicateRogueRemovedNode Some recently-refactored test harness code needed to check for nil stores. Fixes #41466 Release note: None --- pkg/storage/client_raft_helpers_test.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/storage/client_raft_helpers_test.go b/pkg/storage/client_raft_helpers_test.go index 48a26baad47e..110f41a4e39f 100644 --- a/pkg/storage/client_raft_helpers_test.go +++ b/pkg/storage/client_raft_helpers_test.go @@ -133,19 +133,31 @@ func (h *mtcStoreRaftMessageHandler) HandleRaftRequest( req *storage.RaftMessageRequest, respStream storage.RaftMessageResponseStream, ) *roachpb.Error { - return h.mtc.Store(h.storeIdx).HandleRaftRequest(ctx, req, respStream) + store := h.mtc.Store(h.storeIdx) + if store == nil { + return roachpb.NewErrorf("store not found") + } + return store.HandleRaftRequest(ctx, req, respStream) } func (h *mtcStoreRaftMessageHandler) HandleRaftResponse( ctx context.Context, resp *storage.RaftMessageResponse, ) error { - return h.mtc.Store(h.storeIdx).HandleRaftResponse(ctx, resp) + store := h.mtc.Store(h.storeIdx) + if store == nil { + return errors.New("store not found") + } + return store.HandleRaftResponse(ctx, resp) } func (h *mtcStoreRaftMessageHandler) HandleSnapshot( header *storage.SnapshotRequest_Header, respStream storage.SnapshotResponseStream, ) error { - return h.mtc.Store(h.storeIdx).HandleSnapshot(header, respStream) + store := h.mtc.Store(h.storeIdx) + if store == nil { + return errors.New("store not found") + } + return store.HandleSnapshot(header, respStream) } // mtcPartitionedRange is a convenient abstraction to create a range on a node From a1467814e082a60634c6922a2139296fd53a3fa8 Mon Sep 17 00:00:00 2001 From: Matt Jibson Date: Mon, 14 Oct 2019 13:53:01 -0600 Subject: [PATCH 2/2] sqlsmith: fix merge join to exit when it's out of indexes Release note: None --- pkg/internal/sqlsmith/relational.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/internal/sqlsmith/relational.go b/pkg/internal/sqlsmith/relational.go index 47ffd3463aa8..be80f7018fa1 100644 --- a/pkg/internal/sqlsmith/relational.go +++ b/pkg/internal/sqlsmith/relational.go @@ -326,6 +326,9 @@ func makeMergeJoinExpr(s *Smither, _ colRefs, forJoin bool) (tree.TableExpr, col item: tree.NewColumnItem(rightAliasName, rightColElem.Column), }, }) + if len(cols) >= len(leftIdx.Columns) { + break + } } if len(cols) > 0 { return rightTableName, cols