Skip to content

[#310] Background cleanup of removed entries is disabled even if ChronicleMapBuilder#cleanupRemovedEntries is true - #610

Draft
peter-lawrey wants to merge 1 commit into
developfrom
fix/Chronicle-Map-310-remove-shutdown-insensitive-early
Draft

[#310] Background cleanup of removed entries is disabled even if ChronicleMapBuilder#cleanupRemovedEntries is true#610
peter-lawrey wants to merge 1 commit into
developfrom
fix/Chronicle-Map-310-remove-shutdown-insensitive-early

Conversation

@peter-lawrey

@peter-lawrey peter-lawrey commented Aug 20, 2026

Copy link
Copy Markdown
Member

What changed

The removed-entry cleanup thread no longer exits before doing work, and map close now interrupts and joins that thread before the base close path inspects or releases map contexts. Head: 12287ca6.

Why

Activating the previously dormant thread exposed a lifecycle race: close could release the cleanup thread's iteration context during a segment scan, causing cleanup lock errors and MemoryLeaksTest null dereferences. The thread must stop before context teardown.

Impact

Configured tombstone cleanup runs, while explicit close and cleaner-based resource release retain their existing safety guarantees.

Review status

Draft — coherent local fix, awaiting maintainer review.

Validation

  • mvn -o -B -Dtest=OldDeletedEntriesCleanupTest,MemoryLeaksTest -Dsurefire.failIfNoSpecifiedTests=false test: 17 tests passed.
  • mvn -o -B clean test: 1,317 tests, 82 skipped, no failures/errors at 12287ca6 in 1:36.
  • git diff --check: passed.
  • Remote CI and maintainer review remain required.

Tracking

Fixes #310.

Wait out the cleanup thread startup delay instead of terminating before the first scan. Pass the remaining relative duration to parkNanos so valid sub-millisecond cleanup intervals cannot stall after one cycle.

Stop and join the cleaner before Chronicle Map releases registered contexts. Bound the join by the segment-lock timeout, preserve caller interrupt status, and fail without releasing resources if the cleaner cannot exit safely.

Add deterministic coverage for background tombstone removal, repeated microsecond cleanup cycles, relative nanosecond sleeping, close ordering, interruption, and the bounded timeout path.

Fixes #310
@peter-lawrey
peter-lawrey force-pushed the fix/Chronicle-Map-310-remove-shutdown-insensitive-early branch from 12287ca to e2efe0d Compare August 22, 2026 11:00
@peter-lawrey
peter-lawrey changed the base branch from ea to develop August 22, 2026 11:13
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.

Background cleanup of removed entries is disabled even if ChronicleMapBuilder#cleanupRemovedEntries is true

1 participant