Skip to content

Comments

fix: add safety guards to remove() in Simple and Normal#17

Draft
Koan-Bot wants to merge 1 commit intocern-mig:masterfrom
atoomic:koan.atoomic/fix-race-conditions-v2
Draft

fix: add safety guards to remove() in Simple and Normal#17
Koan-Bot wants to merge 1 commit intocern-mig:masterfrom
atoomic:koan.atoomic/fix-race-conditions-v2

Conversation

@Koan-Bot
Copy link

Summary

  • Simple::remove(): Add lock check before removing — attempting to remove an unlocked element now raises a clear error instead of silently corrupting state
  • Normal::remove(): Add retry limit (10) to the lock contention loop — prevents infinite loops if another process repeatedly re-locks a contested element

Motivation

Both issues are edge cases around concurrent access:

  1. Calling remove() on an unlocked element in Simple.pm would unlink the data file without checking for a lock, potentially leaving orphaned state
  2. The while(1) loop in Normal.pm's remove() could spin indefinitely under pathological lock contention

Test plan

  • Existing test suite passes (237 tests)
  • Manual verification of error messages with invalid states

Supersedes #7 (which was polluted with unrelated commits from fork infrastructure).

🤖 Generated with Claude Code

…move()

Simple::remove(): add lock verification before attempting to unlink
files. Without this, calling remove() on an unlocked element would
fail trying to unlink a non-existent .lck file with a confusing error.

Normal::remove(): add a retry limit (10) to the lock contention loop
in remove(). Without this, an infinite loop could occur if another
process keeps re-locking the element during removal.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant