apache/gravitino

[Improvement] Fix async drop-event log throttling race in AsyncQueueListener

Open

#10.169 aberto em 4 de mar. de 2026

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)Java (887 forks)auto 404
good first issueimprovement

Métricas do repositório

Stars
 (3.058 stars)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

What would you like to be improved?

AsyncQueueListener.logDropEventsIfNecessary() uses atomic counters, but its 60-second log-throttling timestamp (lastRecordDropEventTime) is unsynchronized shared state. Under concurrent drops, threads can evaluate the time gate with stale data, causing throttling to break (duplicate warnings within the same window, or incorrect skip behavior).

How should we improve?

Make the rate-limit decision and update the atomic state across both the counter and timestamp. A minimal fix is to ensure visibility of the timestamp (e.g., with volatile) and keep update ordering consistent; a stronger fix is to guard the entire check-and-update block with a lock (or equivalent atomic structure) so that “time gate + counter CAS + timestamp update” behaves as a single critical section.

Guia do colaborador