Skip to content

lib/logstorage: prevent delete tasks from merging replaced parts - #1659

Open
func25 wants to merge 1 commit into
masterfrom
race-delete-vs-merge
Open

lib/logstorage: prevent delete tasks from merging replaced parts#1659
func25 wants to merge 1 commit into
masterfrom
race-delete-vs-merge

Conversation

@func25

@func25 func25 commented Aug 2, 2026

Copy link
Copy Markdown
Member

Deletion searches for matching parts outside partsLock. But there is a race window that a part can be merged and replaced after the search finishes but right before the deletion task claims it, this causes a panic as we are trying to merge (of deletion) a suppose-to-delete part.

// check matching part
if !pw.p.hasMatchingRows(pso, stopCh) {
	continue
}

// --- RACE window

// claim
ddb.partsLock.Lock()
if !pw.isInMerge {
	pw.isInMerge = true
	pwsToMerge = append(pwsToMerge, pw)
} else {
	needRepeat = true
}
ddb.partsLock.Unlock()

Move mustDrop marking under partsLock and check it before the deletion task claims a part, so replaced parts are retried instead.

@func25
func25 requested a review from valyala August 2, 2026 08:44

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Re-trigger cubic

@func25 func25 added the bug Something isn't working label Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant