From c5e46e4618c007fcfc962860b89ab5d84c6fd0ba Mon Sep 17 00:00:00 2001 From: "Jason E. Aten" Date: Sat, 24 Oct 2020 00:20:30 +0000 Subject: [PATCH] one copy of shard map during a reload --- dbshard.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dbshard.go b/dbshard.go index ff8ae5c53..ede2959f0 100644 --- a/dbshard.go +++ b/dbshard.go @@ -266,6 +266,8 @@ func (ss *shardSet) CloneMaybe() map[uint64]bool { return ss.readonly } + //vv("888888 CloneMaybe updating to version %v with %v shards", ss.shardsVer, len(ss.shards)) + // readonlyVer is out of date. // readonly needs update. We cannot // modify the readonly map in place; @@ -515,10 +517,15 @@ func (per *DBPerShard) updateIndex2ShardCacheWithNewShard(dbs *DBShard) { if !ok { shardset = newShardSet() mapIndex2shardSet[dbs.Index] = shardset + //vv("888888 made new shardset for shard dbs.Shard=%v", dbs.Shard) } // INVAR: shardset is present, not nil; a map that can be added to. - shardset.shards[dbs.Shard] = true - shardset.shardsVer++ // invalid the readonly copy, force cloning it anew. + _, already := shardset.shards[dbs.Shard] + if !already { + shardset.shards[dbs.Shard] = true + shardset.shardsVer++ // invalid the readonly copy, force cloning it anew. + //vv("888888 updated to shardset version %v with %v shards", shardset.shardsVer, len(shardset.shards)) + } } }