warrenfalk / rocksdb-sharp

.net bindings for the rocksdb by facebook
Other
208 stars 64 forks source link

RocksDb Dispose stalls forever #68

Open foresightyj opened 5 years ago

foresightyj commented 5 years ago

Attached screenshot shows that the program never gets out of the using statement.

image

warrenfalk commented 5 years ago

I did not reproduce this behavior. I created a new dotnet core application, installed RocksDbSharp and RocksDbNative (v6.2.2 of both). Typed in your example and ran it and it did exit.

image

Do you have any additional information you can provide?

Hanging on dispose like this is an indication that there is some sort of issue with the native interface which I have seen happen if it is loading an older version of the native library. (I.e. RocksDbSharp is 6.2.2 but the native dll that it loads is actually 5.4.x)

foresightyj commented 5 years ago

@warrenfalk

Here is my test project: TestRocksDb.zip. My computer is a Windows 7 machine.

I ran this project in another computer (Windows 2008 Server) and the result is the same. I also tried creating a dot net core project and the result is also the same.

Versions of both library are 6.2.2, and both computers have SSD.

Here I also upload the project including actual built assemblies (excluding packages folder which contains nuget packages).

TestRocksDb.zip

foresightyj commented 5 years ago

@warrenfalk

FYI. Version 5.17.2 works fine in my computer. I am going to use it for now.

warrenfalk commented 5 years ago

When I open the solution in the zip in Visual Studio and run it, I immediate get the error "Unable to locate rocksdb native library, either install it, or use RocksDbNative nuget package". This happens because there is no native dll under a runtimes folder in bin\Debug.

I believe this is true for you too, except in your environment RocksDbNative is finding an older version of the native dll elsewhere. As stated earlier, I believe that an older version can result in this hanging. So in my environment I get "unable to locate" and in your environment you get a hang.

If true, the real issue is that the native dll is not found, and if you open the solution in your zip and run it, you will not find a runtimes folder under bin\Debug folder that contains native dlls.

But if I delete the .vs folder in your zip and run it, it runs and exits fine with no error or hanging.

In .Net Framework, the management of native dlls has always been a little bit broken (this is fixed in dotnet core, where this doesn't happen). Who knows what Visual Studio is saving in that .vs folder, but I believe something went wrong the first time. I was also able to fix this issue simply by uninstalling RocksDbNative and then reinstalling it in the PackageManager console. YMMV with this. I am also using Visual Studio 2019 and I see you are using 2017.

MGRussell commented 4 years ago

I had the exact same issue here, which feels like deadlock. I suspect the culprit may be the OS. Like the original poster, I am also using Windows 7.

I tested this in both a new .NET Framework forms project and a .NET Core console project. Dispose hung on both.

Definitely no older references as I've never installed anything related to rocks on this system before.


Expanding upon this. I just cloned the project. It hangs on the call to

Native.Instance.rocksdb_close(Handle);

In particular on the call to rocksdb_close(...)