apm-server icon indicating copy to clipboard operation
apm-server copied to clipboard

TBS: potential data loss in race condition between event arrival and receiving decision

Open carsonip opened this issue 7 months ago • 0 comments

As TBS pebble implementation does not use db transaction and there are no locks, theoretically it is possible for the following sequence of events to happen.

  1. goroutine A: a trace event T belonging to trace id 123 to arrive
  2. goroutine A: confirm that no decision is made for trace id 123
  3. goroutine B: make a sampling decision for trace id 123
  4. goroutine B: publish all events for trace id 123
  5. goroutine A: write trace event T to pebble
  6. trace event T will sit in pebble until being deleted at TTL

Confirm if this is possible by adding a unit test, and if so, add a fix and measure the perf hit.

carsonip avatar Jul 22 '25 16:07 carsonip