-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: 6.0.0, 7.0.0, 8.1.0-rc0, 8.0.0
-
Component/s: None
-
None
-
Catalog and Routing
Time series collections exist as a combination of a system.buckets.<name> collection, plus a <name> view over that collection.
Currently, locks for those two namespaces are independent and obtained separately (using CollectionAcquisition, CollectionLock, ..). Furthermore, timeseries DDLs (create, drop, etc.) currently lock only the buckets or the view namespace separately, or take a lock on the system.buckets namespace first; while non-timeseries DDLs never take locks on the system.buckets namespace. This pattern is very prone to races, hard to reason about, and makes issues such as SERVER-90862, SERVER-92271, SERVER-95760 hard to fix.
This issue proposes simplifying this pattern by unifying / fusing the locks so that locking either of the view or the buckets namespace will lock the same underlying resource, so effectively both namespaces would always be simultaneously and atomically locked by taking a single lock on either namespace.
Technically, this could be achieved by stripping the system.buckets prefix in NamespaceString::toStringForResourceId, so both namespaces map to the same ResourceId. This generalizes the approach of SERVER-81484 for ShardingDDLCoordinators to the Locker.
This approach should not break existing code (as it only makes locks more goarse-grained) nor introduce deadlocks when existing code attempts to lock both the view and buckets namespaces (because collection locks are re-entrant).
- is depended on by
-
SERVER-90862 Creating a collection or a view should fail if a bucket namespace exists without its view
- Backlog
-
SERVER-92271 Renaming a collection or a view should fail if a buckets namespace exists
- Backlog
-
SERVER-95760 $out: acquire locks for target namespaces when outputting to timeseries
- Blocked