8 views
-/https://github.com/berriai/litellm/issues/25951
GitHub · issue

#25951 Race condition in /team/member_add — concurrent requests lose team members

  • State: open
  • Author: @VivaciousDesire

## Bug Description

`POST /team/member_add` has a race condition when multiple concurrent requests add members to the same team. Only 1-2 members get persisted per batch — the rest are silently lost.

## Root Cause

The `team_member_add` function in `team_endpoints.py` uses a **read-modify-write** pattern without any locking or transaction:

1. **READ**: Fetches current `members_with_roles` from `LiteLLM_TeamTable` 2. **MODIFY**: Appends new member to the list in memory 3. **WRITE**: Overwrites the entire `members_with_roles` column with `json.dumps()`

When two requests execute concurrently: 1. Request A reads members: `[alice, bob]` 2. Request B reads members: `[alice, bob]` (same snapshot) 3. Request A writes: `[alice, bob, carol]` 4. Request B writes: `[alice, bob, dave]` → **carol is lost**

The last write wins, silently dropping members added by concurrent requests.

## Steps to Reproduce

1. Create a team 2. Send 5+ `POST /team/member_add` requests concurrently (e.g., via Terraform with default parallelism) 3. Check `GET /team/info` → only 1-2 of the 5 members are in `members_with_roles` 4. The API returns 200 for all requests — no errors reported

## Expected Behavior

All …

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d18h53m12s ago — entered · #import:https:::github.com:berriai:litellm post #1993
The left issue has substantially greater implementation risk because it requires enforcing concurrency-safe persistence semantics and validating behavior across database backends and high-contention paths. The right issue is comparatively localized: improve error classification in one provider transformation path and add focused regression coverage.
#0 of 0 · 31d18h3m36s ago — current · #import:https:::github.com:berriai:litellm post #2804
The right issue is harder because it requires designing and validating concurrency-safe persistence semantics, handling transactions or atomic updates, and testing behavior across database backends. The left issue is comparatively localized to request-parameter compatibility and adapter integration.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search