Skip to content
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

Error AccessViolationException ClientSession.Read on snapshot #937

Open
cschuchardt88 opened this issue Mar 7, 2025 · 0 comments
Open

Comments

@cschuchardt88
Copy link

Example

_store.TryInitiateFullCheckpoint(out var snapshotId, CheckpointType.Snapshot);
_store.CompleteCheckpointAsync().AsTask().GetAwaiter().GetResult();
_store.Log.FlushAndEvict(true);
return new FasterDbSnapshot(this, _checkpointSettings, snapshotId);
//....
_snapshot = NullStorageDevice.Create(_checkpointSettings, out _logSettings);

_snapshot.Recover(_snapshotId);

_sessionPool = new(
    _logSettings.LogDevice.ThrottleLimit,
    () => _snapshot.For(new ByteArrayFunctions()).NewSession<ByteArrayFunctions>());
//...
public byte[]? TryGet(byte[] key)
{
    if (_sessionPool.TryGet(out var session) == false)
        session = _sessionPool.Get();

    var (status, output) = session.Read(key);  // <--- Throws Here, status is "FOUND", "output" is exception
    byte[]? value = null;

    if (status.Found)
        value = output;
    if (status.IsPending && session.CompletePendingWithOutputs(out var iter, true, true))
    {
        using (iter)
        {
            while (iter.Next())
            {
                if (iter.Current.Key.AsSpan().SequenceEqual(key))
                {
                    value = iter.Current.Output;
                    break;
                }
            }
        }
    }

    _sessionPool.Return(session);

    return value;
}

Exception

System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

CallStack

 	FASTER.core.dll!FASTER.core.ByteArrayFasterEqualityComparer.Equals(ref byte[] k1, ref byte[] k2)	Unknown
 	FASTER.core.dll!FASTER.core.FasterKV<byte[], byte[]>.TraceBackForKeyMatch(ref byte[] key, ref FASTER.core.RecordSource<byte[], byte[]> recSrc, long minAddress)	Unknown
 	FASTER.core.dll!FASTER.core.FasterKV<byte[], byte[]>.InternalRead<byte[], byte[], FASTER.core.Empty, FASTER.core.ClientSession<byte[], byte[], byte[], byte[], FASTER.core.Empty, Neo.Build.Core.Storage.ByteArrayFunctions>.InternalFasterSession>(ref byte[] key, long keyHash, ref byte[] input, ref byte[] output, long startAddress, ref FASTER.core.Empty userContext, ref FASTER.core.FasterKV<byte[], byte[]>.PendingContext<byte[], byte[], FASTER.core.Empty> pendingContext, FASTER.core.ClientSession<byte[], byte[], byte[], byte[], FASTER.core.Empty, Neo.Build.Core.Storage.ByteArrayFunctions>.InternalFasterSession fasterSession, long lsn)	Unknown
 	FASTER.core.dll!FASTER.core.FasterKV<byte[], byte[]>.ContextRead<byte[], byte[], FASTER.core.Empty, FASTER.core.ClientSession<byte[], byte[], byte[], byte[], FASTER.core.Empty, Neo.Build.Core.Storage.ByteArrayFunctions>.InternalFasterSession>(ref byte[] key, ref byte[] input, ref byte[] output, FASTER.core.Empty context, FASTER.core.ClientSession<byte[], byte[], byte[], byte[], FASTER.core.Empty, Neo.Build.Core.Storage.ByteArrayFunctions>.InternalFasterSession fasterSession, long serialNo)	Unknown
 	FASTER.core.dll!FASTER.core.ClientSession<byte[], byte[], byte[], byte[], FASTER.core.Empty, Neo.Build.Core.Storage.ByteArrayFunctions>.Read(ref byte[] key, ref byte[] input, ref byte[] output, FASTER.core.Empty userContext, long serialNo)	Unknown
 	FASTER.core.dll!FASTER.core.ClientSession<byte[], byte[], byte[], byte[], FASTER.core.Empty, Neo.Build.Core.Storage.ByteArrayFunctions>.Read(byte[] key, FASTER.core.Empty userContext, long serialNo)	Unknown
>	Neo.Build.Core.dll!Neo.Build.Core.Storage.FasterDbSnapshot.TryGet(byte[] key) Line 114	C#
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

No branches or pull requests

1 participant