Improve lock contention getting collection CIDs

Description

CouchbaseCollection.PopulateCidAsync is called whenever the collection doesn't have a CID yet (which is always the case the first time the collection is used). If there is a sudden spate of requests for operations on the collection, they may all call PopulateCidAsync and find the CID unpopulated nearly simultaneously.

The current approach has each of them wait 2.5s for a lock to become available. The first one to acquire the lock does the operation and then releases the lock. The others will then acquire the lock and find the CID has been set and return.

This approach causes all of the operations which flooded in to wait for a lock asynchronously. They can then only process one at a time as they each acquire the lock, and as they release it the next waiter is scheduled on the thread pool. This is very slow and can cause timeouts as some of the operations never receive the lock before the 2.5s timeout.

Environment

None

Gerrit Reviews

None

Release Notes Description

None

Activity

Show:

Brant Burnett November 23, 2021 at 8:41 PM

FYI, since you originally mentioned this one to me.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Story Points

Components

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created November 23, 2021 at 8:40 PM
Updated December 3, 2021 at 3:09 AM
Resolved December 3, 2021 at 3:09 AM
Instabug