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

Akka Persistence Throwing Unobserved Task Exception #7358

Open
stedmanm opened this issue Oct 7, 2024 · 3 comments · May be fixed by #7362
Open

Akka Persistence Throwing Unobserved Task Exception #7358

stedmanm opened this issue Oct 7, 2024 · 3 comments · May be fixed by #7362

Comments

@stedmanm
Copy link

stedmanm commented Oct 7, 2024

Version Information
Version of Akka.NET? 1.5.28
Which Akka.NET Modules? Akka.Persistence

Describe the bug
Bug appears to be in method CallThrough of class AtomicState. If WaitAsync(Timeout timeout) completes before the task implemented by SnapshotStore/Journal, and the task in question throws an exception, then this exception will become unobserved.

To Reproduce

  1. Snapshot loading takes longer than call timeout specified by Akka framework, and Snapshot call throws an exception.

Expected behavior
Would expect Akka framework to observe exception thrown by SnapshotStore/Journal.

Actual behavior
Causes unobserved task exception and crashes our service.

Screenshots
image

Environment
Windows Service and .NET 7

@Aaronontheweb
Copy link
Member

@stedmanm thanks for reporting this! We'll look into it

@Arkatufus
Copy link
Contributor

Arkatufus commented Oct 18, 2024

A fix to this issue will have a very high knock on effect.

To fix this effectively, we'd need to implement cancellation token to all journal/snapshot database related methods to effectively signal a cancellation to the underlying task.

That means implementing methods supporting cancellation tokens to ALL public async API methods that is also backward compatible, this will be a binary breaking change for all persistence plugins.

@Arkatufus
Copy link
Contributor

Arkatufus commented Oct 18, 2024

This is an actual bug, here is a simple reproduction to illustrate this: https://share.linqpad.net/pbjjq82i.linq

An .AsyncWait() call does throw a TimeoutException when the execution time exceeds the timeout argument, but it does not stop the running task, making it a detached task running in the background.

Arkatufus added a commit to Arkatufus/akka.net that referenced this issue Oct 23, 2024
# Conflicts:
#	src/core/Akka.Persistence/Snapshot/SnapshotStore.cs
Arkatufus added a commit to Arkatufus/akka.net that referenced this issue Oct 25, 2024
Arkatufus added a commit to Arkatufus/akka.net that referenced this issue Nov 1, 2024
@Aaronontheweb Aaronontheweb modified the milestones: 1.5.31, 1.5.32 Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants