From 72444f3b87cdaa7cce2bfebe08a21f6862c953cb Mon Sep 17 00:00:00 2001 From: Seebs Date: Mon, 13 Sep 2021 16:23:57 -0500 Subject: [PATCH] add clusters to MutexCheck test, fix silly bug revealed by doing so The merge lists behavior was flawed in that it would drop one item from the list per merge, which means that, with high replication and low number of distinct items, it could even produce an empty list. The actual "is there anything wrong" logic is fine, but the list of clashing values set for a given record is not. Unfortunately this also doubles the time the test takes, to 21 seconds on MacOS. OW. --- api.go | 8 ++++---- api_test.go | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/api.go b/api.go index fe5723365..8e7fa7b2b 100644 --- a/api.go +++ b/api.go @@ -2692,9 +2692,9 @@ func mergeIDLists(dst []uint64, src []uint64) []uint64 { return dst[i] < dst[j] }) // dedup. - n := 0 + n := 1 prev := dst[0] - for i := 0; i < len(dst); i++ { + for i := 1; i < len(dst); i++ { if dst[i] != prev { dst[n] = dst[i] n++ @@ -2712,9 +2712,9 @@ func mergeKeyLists(dst []string, src []string) []string { return dst[i] < dst[j] }) // dedup. - n := 0 + n := 1 prev := dst[0] - for i := 0; i < len(dst); i++ { + for i := 1; i < len(dst); i++ { if dst[i] != prev { dst[n] = dst[i] n++ diff --git a/api_test.go b/api_test.go index e4826374f..50a59a03e 100644 --- a/api_test.go +++ b/api_test.go @@ -860,7 +860,13 @@ type mutexCheckField struct { } func TestAPI_MutexCheck(t *testing.T) { - c := test.MustRunCluster(t, 3) + c := test.MustNewCluster(t, 3) + for _, c := range c.Nodes { + c.Config.Cluster.ReplicaN = 2 + } + if err := c.Start(); err != nil { + t.Fatalf("starting cluster: %v", err) + } defer c.Close() m0 := c.GetNode(0)