-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Describe the bug
I regulary get an exception during pull: System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed.
To Reproduce
Not so easy to reproduce in a simple use case. I have a synch of about 15 tables. And you probably need a lot of data so database operations aren't too fast.
I already debugged and found the issue, see at the bottom of this description.
Expected behavior
Exception not thrown.
What platforms?
Note: Any bug or feature request that is opened for an unsupported environment will be automatically closed.
-
Server:
- Version of dotnet being used to compile? 9
- Library versions? 9.0.3
- What database are you using? Microsoft SQL Server
- Where are you running the server? Local debugging environment
- GitHub repository containing the code (optional, but helps!)
-
Client:
- What platform (Android, iOS, Windows, etc.) versions are you running on? Windows MAUI
- Does it happen in an emulator / simulator, or only on a real device? Real device
- Version of dotnet being used to compile? 9
- .NET Runtime Environment (WPF, UWP, WinUI3, MAUI, etc.): MAUI
- Datsync Toolkit NuGet versions? 9.0.3
- GitHub repository containing the code (optional, but helps!)
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Analysis
The problem is in the PullOperationManager.ExecuteAsync code. There is a loop that enques the pull requests in the Queue handler. The loop itself uses the database context to fetch delta tokens. The error seems to occur if a previous enqueued request is already starting while the delta token is fetched for a next one. That causes 2 simultaneous operations on the same context.
I'll create a pull request with a fix.