Skip to content

Fix RavenDb scheduled messages not being delivered when using a durable transport#2554

Merged
jeremydmiller merged 1 commit intoJasperFx:mainfrom
Bishbulb:fix/ravendb-scheduled-job-lock-check
Apr 21, 2026
Merged

Fix RavenDb scheduled messages not being delivered when using a durable transport#2554
jeremydmiller merged 1 commit intoJasperFx:mainfrom
Bishbulb:fix/ravendb-scheduled-job-lock-check

Conversation

@Bishbulb
Copy link
Copy Markdown
Contributor

Summary

I hit this chasing down why bus.ScheduleAsync(...) against a durable external sender was not working in our app - we were seeing saga timeouts persisted to the IncomingMessage collection in RavenDB, but they were never being delivered. We observed that RavenDbDurabilityAgent.runScheduledJobs was never releasing these messages. After some digging, I traced it to RavenDbMessageStore.Locking.cs and found the issue noted below.

Root cause

TryAttainScheduledJobLockAsync decides between its two branches with:

if (_leaderLock == null)

but nothing in this method (or anywhere else that matters to the scheduled lock) reads or writes _leaderLock.

Fix

  • Changing to use the _scheduledLock variable
  • Ensure we set _scheduledLock = null at the end of the method (to match what happens in ReleaseLeadershipLockAsync)

@Bishbulb Bishbulb force-pushed the fix/ravendb-scheduled-job-lock-check branch from 4233129 to 393d2bf Compare April 21, 2026 15:04
@Bishbulb Bishbulb force-pushed the fix/ravendb-scheduled-job-lock-check branch from 393d2bf to 195b5cf Compare April 21, 2026 15:18
Copy link
Copy Markdown
Member

@jeremydmiller jeremydmiller left a comment

Choose a reason for hiding this comment

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

Thanks for the clean fix and regression test.

@jeremydmiller jeremydmiller merged commit d6609b7 into JasperFx:main Apr 21, 2026
dmytro-pryvedeniuk pushed a commit to dmytro-pryvedeniuk/wolverine that referenced this pull request Apr 22, 2026
Adds a CIRavenDb Nuke target that builds and exercises both RavenDbTests
and RavenDbTests.LeaderElection one class (or one method, for leader
election) at a time with retry, plus a dedicated GitHub Actions workflow.
RavenDb tests use the embedded RavenDB.TestDriver, so no docker services
are required.

Also fixes DiscoverTestMethods so inherited [Fact] methods on a compliance
base class (e.g. LeadershipElectionCompliance) are attributed to the
concrete derived class — previously leader-election projects discovered
zero methods, silently running nothing.

Includes the merged community fixes (JasperFx#2554, JasperFx#2555) which repair RavenDb
scheduled-job locking and guard RavenDb durability recovery against
orphaned listener URIs; both ship with regression tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

2 participants