apache/gravitino

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

Open

#10,169 opened on Mar 4, 2026

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

Repository metrics

Stars
 (3,058 stars)
PR merge metrics
 (PR metrics pending)

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.

Contributor guide