1

I'm currently experimentig with FoundationDB in a .Net WebApi 2 project. The WebApi controller performs a simple getrange against the foundationdb cluster, and everything works fine ... if I run the project just once.

The second time I run it, I get the dreaded api_version_already_set error, and the only way to have everything up and running again is to restart IIS. I've found this similar question, and the only "solution" proposed in the answer is to run a process per App Domain, that isn't really ideal.

I have also tried this hack used in the .Net library, but all it does is switch the api_version_already_set error to network_already_setup or broken_promise. Has anybody else found a better solution?

PS: To temporarly solve this, I'm running the WebApi as self host, and this seems to solve the problem, but makes the use of FoundationDB in conjunction with WebApi annoying outside of a test environment.

Save
  • 11,450
  • 1
  • 18
  • 23

1 Answers1

0

This issue is still present in version 5.x, for the same reason. The network thread can only be created (and shut down) once per process, so any host that use multiple Application Domain per process will not work. There does not seem to be any incentive to solve this issue (that mostly only impact managed platforms like .NET, maybe Java?).

Fortunately, with ASP.NET Core and web hosts like Kestrel (out of process, does not use AppDomains), this issue will become moot.

This can still cause issues with unit test runners that attempt to cache the process between runs. You need to disable this caching feature for them to run reliably.