Couchbase randomly crashing during tests
See original GitHub issueLibrary Version
CouchbaseLite/3.0.0 - Build/124 - Commit/f733cb70
.NET Runtime
.NET (Core) 5.0
Operating System / Device Details
Ubuntu 20.04
Expected behavior
Xunit tests should run smoothly and pass.
Actual behavior
By running the tests multiple times, we get different results (no changes to the code or the environment were made by us in between). Either :
- Everything is fine and tests pass
- I get an exception when trying to create a database
Error Message:
Couchbase.Lite.CouchbaseLiteException : CouchbaseLiteException (LiteCoreDomain / 11): can't open file.
Stack Trace:
at LiteCore.Interop.NativeHandler.ThrowOrHandle()
at LiteCore.Interop.NativeHandler.Execute(C4TryLogicDelegate2 block)
at LiteCore.LiteCoreBridge.Check(C4TryLogicDelegate2 block)
at Couchbase.Lite.Database.<>c__DisplayClass101_0.<Open>b__0()
at Couchbase.Lite.Support.ThreadSafety.DoLocked(Action a)
at Couchbase.Lite.Database.Open()
at Couchbase.Lite.Database..ctor(String name, DatabaseConfiguration configuration)
- The tests crash and I get the following message :
The active test run was aborted. Reason: Test host process crashed : double free or corruption (fasttop)
Steps To Reproduce
- Create a Xunit project
- Create Xunit test classes and tests
- In each test class constructor, create a new database :
new Database(Guid.NewGuid().ToString())
- Clear the database in the constructor and delete and dispose it in a Dispose method
- Execute operations on the database in the tests (CRUD)
- Run
dotnet tests
to launch all tests (multiple times to get the different results)
Reproduction Project
I’ll try to create one soon !
Further comments
- I haven’t been able to find a pattern in the way tests pass, crash or throw the exception
- There are 5 tests classes creating a new database with at least 5 tests in each (so there will be more than 25 databases created)
- Our tests were written to test repository classes which encapsulate the database, but the tests or the repositories don’t appear to be the culprits (the exception seems related to Couchbase and the crash message to C/C++).
Do you have any clue as to why this is happening ? Tell me if there is more I can do to help Billuc
Issue Analytics
- State:
- Created a year ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Net Couchbase SDK randomly crashes IIS process
Some strange behaviour occurs randomly (once a day), crashing the IIS worker. On testing environments this does not happen.
Read more >TestServer app randomly crashes with System. ...
Builds .net UWP b0634, SG 2.0.0-823, CBS 5.1.0-5552 Test ran Started the entire set of replication tests ... TestServer app randomly crashes with...
Read more >Top 6 reasons mobile apps crash
Mobile apps can crash for a hundred different reasons. Experts share their thoughts on the primary causes of crashes and how to fix...
Read more >Couchbase vs RavenDB: Performance at Rakuten Kobo
Rakuten Kobo evaluates Couchbase and RavenDB for their eBook enterprise app. Databases are measured by performance, cost savings, and ease of use.
Read more >A High Data Density Storage Engine Used in Couchbase
In a limited memory setup like. 100x database size to memory ratio, most reads will incur cache miss and every lookup can lead...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
.Net 5 is not officially supported. CBL issue is created to verify if the issue with the given steps here can be reproduced in .Net Core 3.1 and .Net 6.
Ok, I think I found what went wrong ! I haven’t got the time to create a repro so I can’t be 100% sure though.
As I explained earlier, each of our test creates a brand new database and deletes it after the test is finished. While fiddling with my tests, I noticed that when the number of tests was quite small everything goes well, but once the number of tests running in parallel becomes greater than 32, I get the error mentioned above. It seems I can’t have more than 32 couchbase databases alive at the same time (I may have missed it in the docs).
So to solve the issue, I configured Xunit to stop running tests in parallel and now everything is working properly.