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

NullReferenceException when using AsyncPool #784

Closed
wassim-k opened this issue Jan 18, 2023 · 5 comments · Fixed by #785
Closed

NullReferenceException when using AsyncPool #784

wassim-k opened this issue Jan 18, 2023 · 5 comments · Fixed by #785

Comments

@wassim-k
Copy link

wassim-k commented Jan 18, 2023

I'm using FasterWrapper as suggested by #780 (comment)
But when running the following code, which checkpoints from multiple threads, I'm receving a NullReferenceException at var status = session.Upsert(key, value);

Can you please explain why?

var faster = new FasterWrapper<long, long>(isRefType: false, useLargeLog: false, useOsReadBuffering: false);
await Task.WhenAll(Enumerable.Range(0, 2).Select(async i =>
{
    faster.Upsert(i, i);
    await faster.Store.TakeHybridLogCheckpointAsync(CheckpointType.FoldOver);
}));

I've also noticed in the synchronous variation of methods like Upsert in FasterWrapper, _sessionPool.GetAsync().GetAwaiter().GetResult() is being used instead of the synchronous _sessionPool.Get(), is there reason for that?

@tcsaddul
Copy link

Maybe the same problem here when I upgraded to the latest version that error appears in the Upsert in concurrent calls. After reverting to the previous version, error disappeared.

@wassim-k
Copy link
Author

Worth mentioning I've had this issue happen in 2.2.0 & 2.3.0 versions.

@badrishc
Copy link
Contributor

Can you summarize in detail what's the exact issue in the latest version. Where is the exception, what's the call stack, have your tried any fixes yourself etc.

For sync, you can check the code to see if there is a good reason. I think it's because Try might fail.

@wassim-k
Copy link
Author

Reproduction:

  • Checkout AsyncStress playground
  • Expose public FasterKV<Key, Value> Store => _store; from FasterWrapper<Key, Value>
  • Replace Program's Main method with above code as is.

Exception:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at FASTER.core.ClientSession`6.InternalFasterSession.TryLockEphemeralExclusive(RecordInfo& recordInfo)
   at AsyncStress.FasterWrapper`2.Upsert(Key key, Value value) in C:\Code\AsyncStress\FasterWrapper.cs:line 87
   at AsyncStress.Program.<>c__DisplayClass10_0.<<Main>b__0>d.MoveNext() in C:\Code\AsyncStress\Program.cs:line 70
--- End of stack trace from previous location ---
   at AsyncStress.Program.Main(String[] args) in C:\Code\AsyncStress\Program.cs:line 68
   at AsyncStress.Program.<Main>(String[] args)

The issue happens in v2.2.0 and v2.3.0 but not in v.2.1.0

@badrishc
Copy link
Contributor

Fixed in #785

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

Successfully merging a pull request may close this issue.

3 participants