Skip to content

fix: call proceedNextContext() in reset() and replace test sleeps with semaphores#1011

Open
mPokornyETM wants to merge 1 commit intomasterfrom
fix/988-reset-race-and-test-sleeps
Open

fix: call proceedNextContext() in reset() and replace test sleeps with semaphores#1011
mPokornyETM wants to merge 1 commit intomasterfrom
fix/988-reset-race-and-test-sleeps

Conversation

@mPokornyETM
Copy link
Copy Markdown
Contributor

Fixes #988

Problem

LockableResourcesManager.reset() clears all resource state (lock, reservation, queued context) but never calls proceedNextContext(). Every other method that frees resources (unlockResources(), unreserve(), �ddResource()) does call it. This means waiting pipeline jobs are never notified when resources become free via
eset(), causing a race condition.

Fix

Added while (proceedNextContext()) {} loop inside
eset(), consistent with all other resource-freeing methods.

Test improvements

Replaced all sleep() calls with SemaphoreStep semaphores in 3 test files (4 tests total):

  • LockStepReserveInsideLockHonouredTest — 8 semaphores replace 13 sleeps (~82s → ~20s)
  • LockStepSetReservedByInsideLockHonouredTest — semaphores replace all sleeps (~55s → ~15s)
  • LockStepTest#reserveInsideLockHonoured and #setReservedByInsideLockHonoured — same treatment

Also removed try-catch workarounds for Bug#2 and tightened assertions to fail fast instead of masking race conditions.

@mPokornyETM mPokornyETM requested a review from a team as a code owner April 17, 2026 06:52
@github-actions github-actions Bot added bug java Pull requests that update Java code tests labels Apr 17, 2026
@mPokornyETM mPokornyETM force-pushed the fix/988-reset-race-and-test-sleeps branch 6 times, most recently from 410f0a7 to 09eb732 Compare April 21, 2026 19:35
…h semaphores

Fixes #988

LockableResourcesManager.reset() cleared resource state but never called
proceedNextContext(), so waiting pipeline jobs were never notified when
resources became free via reset(). Every other method that frees resources
(unlockResources, unreserve, addResource) already does this. Added the
same while(proceedNextContext()){} loop inside reset().

Replaced all sleep() calls in the reserve/setReservedBy-inside-lock tests
with SemaphoreStep-based synchronisation, making the tests deterministic
and roughly 4x faster (~20s vs ~80s each). Removed the try-catch Bug#2a
and Bug#2b tolerance blocks since the reset() fix makes them unnecessary.

Affected tests:
- LockStepReserveInsideLockHonouredTest
- LockStepSetReservedByInsideLockHonouredTest
- LockStepTest#reserveInsideLockHonoured
- LockStepTest#setReservedByInsideLockHonoured
@mPokornyETM mPokornyETM force-pushed the fix/988-reset-race-and-test-sleeps branch from 09eb732 to dea0e0a Compare April 22, 2026 10:01
@mPokornyETM mPokornyETM added the merge-in-2-days-without-review Auto-approve countdown label Apr 22, 2026
@github-actions github-actions Bot added merge-in-1-day-without-review Auto-approve countdown and removed merge-in-2-days-without-review Auto-approve countdown labels Apr 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Auto-merge countdown: This PR will be auto-approved in 1 day(s) if no review is submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug java Pull requests that update Java code merge-in-1-day-without-review Auto-approve countdown tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition: parallel stage can set reservation before first stage logs state

1 participant