Skip to content

Commit 8860c8d

Browse files
praserxCopilot
andauthored
docs: added condition explanation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ae7cf2a commit 8860c8d

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

cache.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ func (a *AtomicCache) Delete(key string) error {
314314
}
315315

316316
shardSection := a.getShardsSectionByID(val.ShardSection)
317+
// Check if the shard at val.ShardIndex is nil. This is a defensive check to
318+
// handle cases where the shard might have been released or not initialized
319+
// due to concurrent modifications or unexpected states.
317320
if shardSection.shards[val.ShardIndex] != nil {
318321
shardSection.shards[val.ShardIndex].Free(val.RecordIndex)
319322
a.releaseShard(val.ShardSection, val.ShardIndex)

0 commit comments

Comments
 (0)