apache/gravitino

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

Open

#10 169 ouverte le 4 mars 2026

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)Java (887 forks)auto 404
good first issueimprovement

Métriques du dépôt

Stars
 (3 058 stars)
Métriques de merge PR
 (Métriques PR en attente)

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.

Guide contributeur