Commit 41de460
authored
[server][test] Fix record-level metric transition timing and test thread leak (linkedin#2553)
[server][test] Fix record-level metric transition timing and test thread leak
- StoreIngestionTask: invoke
`mayResumeRecordLevelMetricsForCurrentVersion()` inside
`processConsumerRecord()` when a partition transitions to complete.
Previously this logic ran only on the SIT `run()` thread, while
record processing occurs on the StoreBufferDrainer thread. After
EOP marked a partition complete, the drainer could process
subsequent records before the SIT loop updated
`recordLevelMetricEnabled`. The flag is now updated on the drainer
thread immediately after the ready-to-serve check so post-EOP
records in the same batch emit full metrics. Guarded by
`!recordLevelMetricEnabled.get() && !wasComplete &&
partitionConsumptionState.isComplete()` to trigger only on actual
transitions and avoid repeated partition-state scans.
- KafkaConsumerServiceDelegatorTest: fix thread leak and misleading
assertion in `testKafkaConsumerServiceResubscriptionConcurrency`.
Resubscription threads are now always interrupted and joined before
assertions to prevent leaks and ensure the real race-condition
failure is not masked by thread-state checks.
Root cause:
- `testRecordLevelMetricForCurrentVersion`: resume logic executed only
on the SIT `run()` loop thread. Because record processing flows
through `ConsumptionTask → StorePartitionDataReceiver →
StoreBufferService → StoreBufferDrainer`, the drainer could process
post-EOP records before the SIT loop set
`recordLevelMetricEnabled = true`, causing
`recordTotalBytesConsumed` to be invoked fewer times than expected.
- `testKafkaConsumerServiceResubscriptionConcurrency`: a
resubscription thread could terminate after throwing an exception
and count down the latch. The thread-state assertion then failed
(TERMINATED vs RUNNABLE/WAITING), obscuring the real race assertion
and leaking other running threads.1 parent 1dfec26 commit 41de460
3 files changed
Lines changed: 12 additions & 16 deletions
File tree
- clients/da-vinci-client/src
- main/java/com/linkedin/davinci/kafka/consumer
- test/java/com/linkedin/davinci/kafka/consumer
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2909 | 2909 | | |
2910 | 2910 | | |
2911 | 2911 | | |
| 2912 | + | |
| 2913 | + | |
2912 | 2914 | | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
2913 | 2921 | | |
2914 | 2922 | | |
2915 | 2923 | | |
| |||
Lines changed: 3 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
| |||
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
361 | | - | |
| 360 | + | |
362 | 361 | | |
| 362 | + | |
363 | 363 | | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | 364 | | |
370 | 365 | | |
371 | | - | |
372 | 366 | | |
| 367 | + | |
373 | 368 | | |
374 | 369 | | |
375 | 370 | | |
376 | | - | |
377 | 371 | | |
378 | 372 | | |
379 | 373 | | |
| |||
Lines changed: 1 addition & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1623 | 1623 | | |
1624 | 1624 | | |
1625 | 1625 | | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
1632 | | - | |
| 1626 | + | |
1633 | 1627 | | |
1634 | 1628 | | |
1635 | 1629 | | |
| |||
0 commit comments