Skip to content

Fix NRE in RavenDb durability recovery#2555

Merged
jeremydmiller merged 1 commit intoJasperFx:mainfrom
Bishbulb:fix/ravendb-durability-nre-orphaned-listener
Apr 21, 2026
Merged

Fix NRE in RavenDb durability recovery#2555
jeremydmiller merged 1 commit intoJasperFx:mainfrom
Bishbulb:fix/ravendb-durability-nre-orphaned-listener

Conversation

@Bishbulb
Copy link
Copy Markdown
Contributor

Summary

I ran into this running multiple Wolverine services against a single shared RavenDb envelope database. Every durability recovery pass was throwing a NullRef exception and spamming the logs every few seconds. I traced it to RavenDbDurabilityAgent.tryRecoverIncomingMessages.

Root cause

The method scans all distinct ReceivedAt URIs in the IncomingMessage collection and calls FindListenerCircuit for each. When a URI belongs to a queue that this node doesn't service (because a different service owns it), FindListenerCircuit returns null which causes an NRE trying to access circuit.Status:

  var circuit = _runtime.Endpoints.FindListenerCircuit(receivedAt)!;
  if (circuit.Status != ListeningStatus.Accepting)

Note that I believe the same issue would occur in a single-service deployment if a listener URI was removed from config (or renamed), at that point any inbox documents that were still referencing the old URI would result in the same null reference exception.

Fix

Null-check the circuit variable and skip it

@Bishbulb Bishbulb force-pushed the fix/ravendb-durability-nre-orphaned-listener branch from c720273 to c546419 Compare April 21, 2026 15:37
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 e2231ce 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