0

I am attempting to update RavenDB storage for hangfire to RavenDB4 and I sometimes receive the following exception:

Raven.Client.Exceptions.RavenException: 'System.InvalidOperationException: A write transaction is already opened by this thread

I checked for unclosed session, but all session but one use using and the last one is specific because it is part of a class that acts like a transaction builder and is disposed on commit. I was unable to find what operations might take longer in the background or what could cause it.

I'd appreciate a little help with narrowing down what could cause this, because I have absolutely no idea and documentation didn't help much.

adsamcik
  • 1,265
  • 12
  • 14
  • This is not specifically RavenDB, but it may be related to your issue: https://stackoverflow.com/questions/6062192/there-is-already-an-open-datareader-associated-with-this-command-which-must-be-c – user7396598 Jan 24 '18 at 22:45
  • Is this something that you can reproduce? It looks like a server side issue, not something you are doing on the client side? – Ayende Rahien Jan 25 '18 at 10:04
  • @AyendeRahien I can reproduce it in that project easily with queuing hundreds of jobs. But I don't know exactly which code sequence causes it since the storage code I am porting from RavenDB3 is called by Hangfire extension and not directly by my code. I forgot to mention that it throws this exception on `session.SaveChanges()`. – adsamcik Jan 25 '18 at 11:58
  • 1
    @AyendeRahien so I got nightly Raven and ran a quick test of 1000 job inserts and executions. Will it was a bit slow (probably my fault, still learning) but it ran without exception so it was probably a bug in the RavenDB 4.0.0-rc-40025 which got solved some time later. I will test it a bit more though to make sure, but it looks promising so far. – adsamcik Jan 25 '18 at 14:11

1 Answers1

0

After upgrading to nightly version of RavenDB4 instead of RavenDB 4.0.0-rc-40025 (after Ayende Rahien suggested it should be a server issue) I never got this exception. I scheduling thousands of jobs before posting this as an answer to make sure it was server side issue.

Before the upgrade I got the exception pretty much every time I scheduled many jobs.

adsamcik
  • 1,265
  • 12
  • 14