Skip to content

move Akka.DistributedData.LightningDb onto vendored package #5180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Aaronontheweb
Copy link
Member

only until CoreyKaylor/Lightning.NET#141 gets resolved

close #5174

@Aaronontheweb Aaronontheweb added the akka-ddata-durable LMDB implementation for persisting durable data label Aug 6, 2021
@Aaronontheweb Aaronontheweb added this to the 1.4.23 milestone Aug 6, 2021
@Aaronontheweb Aaronontheweb enabled auto-merge (squash) August 6, 2021 23:06
@Aaronontheweb
Copy link
Member Author

So I'm able to get LightningDb.NET working just fine on Windows in this PR, so there must be a binary copy issue that's hitting the MNTR. Between LightningDb v0.13 and this vendored version they moved to using two different .DLLs for LightningDb on Windows. That might be part of it. I'll take a closer look at the binary output on a local development machine.

@Aaronontheweb
Copy link
Member Author

I was able to reproduce the issue locally - in does indeed appear to be an issue with the MNTR being unable to resolve the native assembly paths at runtime. I'm not sure why this wasn't an issue before - it could have to do with the .NET Standard 2.0 version of the package resolving different than the .NET Core 3.1 and .NET 5.0 versions since CoreyKaylor/Lightning.NET#138

@@ -4,6 +4,7 @@
<PropertyGroup>
<AssemblyTitle>Akka.DistributedData.Tests.MultiNode</AssemblyTitle>
<TargetFrameworks>$(NetFrameworkTestVersion);$(NetTestVersion);$(NetCoreTestVersion)</TargetFrameworks>
<Platforms>x64</Platforms> <!-- target x64 only due to LightningDb support -->
Copy link
Member Author

Choose a reason for hiding this comment

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

I think AnyCPU might have something to do with the issues here. Going to see if I can get this all to work under x64.

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't appear to have helped, based on the data from my local machine

Copy link
Member Author

Choose a reason for hiding this comment

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

LOL, applied this to the wrong project....

@Aaronontheweb
Copy link
Member Author

On this PR, the structure of my folders from the build output of Akka.Cluster.Sharding.Tests.MultiNode.csproj - all of the output targets have the runtimes folder, where the native .DLLs live, except for net471: https://gist.github.com/Aaronontheweb/99877df36004af89b8ceb8653f02b244

@Aaronontheweb
Copy link
Member Author

Alright, figured this one out - looks like the lmdb.dll is no longer being copied to the same directory as LightningDb.dll and that's why the ImportDLL call fails. Fun.

@Aaronontheweb
Copy link
Member Author

Looks like this is an MSBuild issue with the latest Lightning.NET sources: CoreyKaylor/Lightning.NET#143

Definitely an edge case in how native .DLLs get resolved.

@Aaronontheweb
Copy link
Member Author

Might have to specify the DefaultDllImportSearchPaths inside the Akka.DistributedData.LightningDb package as it seems that the MNTR is unable to search in the runtimes folder produced by the compilation: https://stackoverflow.com/questions/2864673/specify-the-search-path-for-dllimport-in-net/45384763#45384763

Other possibility I'm going to look at is that the MNTR's Runtime Identifier (RID) is at issue.

<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>

@Aaronontheweb
Copy link
Member Author

I've tested this locally and changing the RIDs does not help at all - those directories simply aren't being searched for these DLLs.

@Aaronontheweb
Copy link
Member Author

Looks like this resolved the issue but I need to refine this a tad more....

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to resolve this by re-using the .targets file from the original projects.

Everything using the original LightningDb package runs just fine in a stand-alone project, but the MNTR isn't able to resolve these DLLs when it's running. Best bet is to just stick the DLLs in a folder adjacent to the .NET dlls, which is how things work in the current dev branch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Note: this targets file is only necessary because of the quirks of the MNTR, transitive dependencies, and multi-targeting in MSBuild. A normal software application using Akka.Cluster.Sharding will not have this issue.

@Aaronontheweb
Copy link
Member Author

Bah, looks like I broke the .DLL copying again by trying to share it. I'll need to tweak that again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
akka-ddata-durable LMDB implementation for persisting durable data
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.DllNotFoundException: Unable to load shared library 'lmdb' or one of its dependencies
1 participant