[SERVER-76839] Operations with a CollectionCatalog instance can observe uncommitted collections become committed from a different operation operating on a different CollectionCatalog instance Created: 04/May/23  Updated: 29/Oct/23  Resolved: 08/Jun/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Gregory Wlodarek Assignee: Henrik Edin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-76843 Remove isCommitted from Collection Closed
Problem/Incident
Related
related to SERVER-77895 fsm_workloads /agg_match.js fails due... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Execution Team 2023-05-29, Execution Team 2023-06-12
Participants:
Linked BF Score: 156

 Description   

SERVER-75497 exposed this bug in the CollectionCatalog. In dbHash we started using range(dbName) to hash all collections. There was a BF where we had test.a -> test.b -> test.c but unexpectedly we also tried to hash test_test.d which is when the assertion fired.

This can be reproduced with SERVER-75497 using the following

TEST_F(CollectionCatalogTimestampTest, TestIterator) {
    createCollection(opCtx.get(), NamespaceString("test.1"), Timestamp::min());
    createCollection(opCtx.get(), NamespaceString("test.2"), Timestamp::min());
 
    WriteUnitOfWork wuow(opCtx.get());
    _createCollection(opCtx.get(), {NamespaceString("test_test.3")});
    opCtx->recoveryUnit()->runPreCommitHooks(opCtx.get());
 
    auto newClient = opCtx->getServiceContext()->makeClient("AlternativeClient");
    AlternativeClientRegion acr(newClient);
    auto newOpCtx = cc().makeOperationContext();
 
    auto latest = CollectionCatalog::latest(newOpCtx.get());
    auto range = latest->range(NamespaceString("test.1").dbName());
    auto end1 = range.end();
    wuow.commit();
    auto end2 = range.end();
 
    ASSERT(end1 == end2);
}

In GDB I observed that after the wuow.commit(), _cachedCommitted stays false, but _shared->_committed flips to true in the shared state of the collection.

I don't think _shared->_committed should be shared. In the example above we're thinking about crossing database boundaries through end(). But we can also have something like test.a -> test.b (uncommitted) -> test.c
In Op1: we start iterating, and we're on test.a
In Op2: Commit the WUOW creating test.b
In Op1: we move on to test.b because it's committed.



 Comments   
Comment by Githook User [ 08/Jun/23 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-76839 Remove committed flag in Collection

This fixes inconsistent visibility where readers all of a sudden discovered collections to be visible even though they had a stashed snapshot of the catalog.

It also allows for a lot of simplifications not having to deal with "waiting for visibility" and collections are now fully visible when onCommit handlers execute.
Branch: master
https://github.com/mongodb/mongo/commit/2c9fa903abb7cab0859d600b749bf8eee242a8b4

Comment by Githook User [ 07/Jun/23 ]

Author:

{'name': 'Sviatlana Zuiko', 'email': 'sviatlana.zuiko@mongodb.com', 'username': 'szuiko'}

Message: Revert "SERVER-76839 Remove committed flag in Collection"

This reverts commit c212bd9f6cf4652408b395a530112e76280eb858.
Branch: master
https://github.com/mongodb/mongo/commit/7c1579bf7ab3d29c58dfcadd5cfa53df86af95bb

Comment by Githook User [ 06/Jun/23 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-76839 Remove committed flag in Collection

This fixes inconsistent visibility where readers all of a sudden discovered collections to be visible even though they had a stashed snapshot of the catalog.

It also allows for a lot of simplifications not having to deal with "waiting for visibility" and collections are now fully visible when onCommit handlers execute.
Branch: master
https://github.com/mongodb/mongo/commit/c212bd9f6cf4652408b395a530112e76280eb858

Generated at Thu Feb 08 06:33:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.