Skip to content

Commit eeebe4e

Browse files
committed
Shard release and active shard indication fix
1 parent e25a42e commit eeebe4e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cache.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ func (a *AtomicCache) releaseShard(shardSectionID uint8, shard uint32) bool {
248248

249249
if shardSection.shards[shard].IsEmpty() == true {
250250
shardSection.shards[shard] = nil
251+
252+
shardSection.shardsAvail = append(shardSection.shardsAvail, shard)
253+
for k, v := range shardSection.shardsActive {
254+
if v == shard {
255+
shardSection.shardsActive = append(shardSection.shardsActive[:k], shardSection.shardsActive[k+1:]...)
256+
break
257+
}
258+
}
259+
251260
return true
252261
}
253262

@@ -291,6 +300,7 @@ func (a *AtomicCache) getEmptyShard(shardSectionID uint8) (uint32, bool) {
291300

292301
var shardIndex uint32
293302
shardIndex, shardSection.shardsAvail = shardSection.shardsAvail[0], shardSection.shardsAvail[1:]
303+
shardSection.shardsActive = append(shardSection.shardsActive, shardIndex)
294304

295305
return shardIndex, true
296306
}

0 commit comments

Comments
 (0)