[3.0.4 Backport] Reloading the database while it has a replicator defined on it causes a panic

Description

Defining a replicator on a database then reloading that database will cause an unrecoverable panic. In the CBSE, the database was being reloaded due to network issues.

The panic is to do with trying to register duplicate Prometheus stats.

Repro steps on 1 SG instance
1. Create db1 with bucket1
2. Create db2 with bucket2
3. Create a replicator on db2 with db1 as remote. Can be pull or push and can be continuous or not.
4. Reload database for db2. I did this by modifying db2 config through PUT /db2/_config by adding "import_docs": true to the config.
5. Wait for panic
Repro URL and payloads at bottom

3.1.0 panic message

Repro steps URLs and payloads
PUT 127.0.0.1:4985/db1/

PUT 127.0.0.1:4985/db2/

PUT 127.0.0.1:4985/db2/_replication/repl1

PUT 127.0.0.1:4985/db2/_config

Activity

Show:

CB robot September 14, 2022 at 4:42 PM

Build sync_gateway-3.0.4-5 contains sync_gateway commit ccbbfbb with commit message:
[Backport 3.0.4] : Backport : Unregister Prometheus stats on database close (#5756)

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

Details

Assignee

Reporter

Labels

Components

Fix versions

Priority

Instabug

Open Instabug

PagerDuty

Sentry

Zendesk Support

Created September 13, 2022 at 5:22 PM
Updated August 31, 2024 at 10:59 AM
Resolved September 14, 2022 at 3:05 PM
Instabug