Back to Signal Feed
CodeTracked since May 19, 2026

Document and test concurrent callback re-entry in csync.Map.GetOrSet

This change adds explicit documentation and a focused concurrency test for GetOrSet, clarifying that the provided callback function may execute multiple times when many goroutines contend on the same key, which makes the TOCTOU behavior of the cache helper visible to users.

GetOrSetcsync.MapTOCTOUconcurrent test

What Happened

  • This change adds explicit documentation and a focused concurrency test for GetOrSet, clarifying that the provided callback function may execute multiple times when many goroutines contend on the same key, which makes the TOCTOU behavior of the cache helper visible to users.
  • This change adds explicit documentation and a focused concurrency test for GetOrSet, clarifying that the provided callback function may execute multiple times when many goroutines contend on the same key, which makes the TOCTOU behavior of the cache helper visible to users.
  • 1 evidence item attached for review.

What is Different

Before

Scattered source updates, isolated context, and manual follow-up across multiple feeds.

Now

Documented GetOrSet's concurrency contract that the callback can be invoked repeatedly under contention and added TestMap_GetOrSet_Concurrent (10 goroutines, start barrier, sleep to widen race window, invocation-count logging) to verify this race path and expose repeated-callback behavior.

Why Track This

Why It Matters

Developers calling csync.Map.GetOrSet in Go services should now assume the callback may be triggered concurrently, so code that mutates shared state in the callback can avoid hidden duplicate side effects and race-related production issues by making callback logic idempotent or externally synchronized. This reduces surprise failures during concurrent cache access and gives maintainers a concrete test that reproduces the contention window; continue monitoring whether future changes keep the strict single-execution assertion disabled and whether non-idempotent callback patterns still surface as intermittent logic bugs.

Impact

Developers calling csync.Map.GetOrSet in Go services should now assume the callback may be triggered concurrently, so code that mutates shared state in the callback can avoid hidden duplicate side effects and race-related production issues by making callback logic idempotent or externally synchronized. This reduces surprise failures during concurrent cache access and gives maintainers a concrete test that reproduces the contention window; continue monitoring whether future changes keep the strict single-execution assertion disabled and whether non-idempotent callback patterns still surface as intermittent logic bugs.

What To Watch Next

  • Watch whether GetOrSet becomes a repeated pattern.
  • Track follow-up changes around Code Repository Intelligence.
  • Compare future signals against this evidence trail.
  • Re-check risk flags: callback_not_idempotent_under_contention, implicit_concurrency_assumptions_in_callers.
Open Topic TimelineOpen Technical EventOpen Original Sourcecallback_not_idempotent_under_contention / implicit_concurrency_assumptions_in_callers / single_execution_assertion_not_enforced

Supporting Evidence