influxdata / influxdata/influxdb

InfluxDB creates duplicated legacy mappings on `/dbrps`

Open
#22,622 1 comment 0 reactions 0 assignees View on GitHub
area/2.x area/api area/compat-v1x kind/bug
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

## Steps to reproduce

1. Run two API requests in parallel to create `dbrp` mapping
2. All arguments are the same: database, retention_policy, orgID, bucketID
3. POST http://192.168.0.4:8086/api/v2/dbrps

## Expected behavior
Only one of the requests succeeds, while the other gets rejected

## Actual behavior
Both requests succeed. 🐞 Two equal `dbrp` mappings are created, leading to an invalid state

## Environment info

* System info: Linux-5.11.0-25-generic x86_64
* InfluxDB version: 2.0.7

## Config
All default

## Additional info for bug reproduction
This script can be used to reproduce the bug 100% of time: https://gist.github.com/hinst/5943f75d002eaa2a7398fe2181c81cff

1. Run the script
2. Check the number of mappings using command
3. `influx v1 dbrp list -o HOME`
4. -> there will be two mappings

If the same requests are run in a sequence, and **not** in parallel, then the second request to create the legacy mapping will fail with an error: such mapping already exists

Contributor guide

Open the contributing guide

Research direction

Run the linked reproduction script with two parallel POST requests to /api/v2/dbrps, then inspect the handler and persistence path for legacy mapping creation. Verify the fix by rerunning the parallel requests and checking `influx v1 dbrp list -o HOME` shows one mapping, while sequential duplicate requests still fail.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.