apm-server
apm-server copied to clipboard
TBS: potential data loss in race condition between event arrival and receiving decision
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.
- goroutine A: a trace event T belonging to trace id 123 to arrive
- goroutine A: confirm that no decision is made for trace id 123
- goroutine B: make a sampling decision for trace id 123
- goroutine B: publish all events for trace id 123
- goroutine A: write trace event T to pebble
- 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.