[3.0.1 backport] Fix race condition caused when getting user roles

Description

A race condition has been discovered in GetRoles() caused by the nil check, and the user.roles write being done at the same time when replicating 2 documents (with channels) with a custom sync function, and using users with explicit channels.

This needs to be fixed to make sure this function does not race. This can be done by adding a lock on the userImp struct and then using a read lock, and upgrading it when needed.

Activity

Show:

CB robot March 28, 2022 at 1:02 PM

Build sync_gateway-3.0.1-5 contains sync_gateway commit f0e10de with commit message:
[Backport 3.0.1] : : fixing race condition caused when getting user roles (#5484)

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

Details

Assignee

Reporter

Story Points

Components

Sprint

Fix versions

Affects versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created March 21, 2022 at 5:49 PM
Updated August 31, 2024 at 10:59 AM
Resolved March 28, 2022 at 1:28 PM
Instabug