question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Couchbase randomly crashing during tests

See original GitHub issue

Library 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 :

  1. Everything is fine and tests pass
  2. 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)
  1. 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

  1. Create a Xunit project
  2. Create Xunit test classes and tests
  3. In each test class constructor, create a new database : new Database(Guid.NewGuid().ToString())
  4. Clear the database in the constructor and delete and dispose it in a Dispose method
  5. Execute operations on the database in the tests (CRUD)
  6. 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:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Sandychuang8commented, May 23, 2022

.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.

0reactions
Billuccommented, Feb 27, 2023

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found