Details
-
Bug
-
Status: Resolved
-
Low
-
Resolution: Fixed
-
None
-
Code - Bug - Unclear Impact
-
Low
-
Low Hanging Fruit
-
Code Inspection
-
All
-
None
-
Description
Within org.apache.cassandra.db.commitlog.AbstractCommitLogService
we use System.currentMillis()-based time to initialize lastSyncedAt field:
protected volatile long lastSyncedAt = currentTimeMillis();
but later we use clock.now() = System.nanoTime() to compare and update the field value:
long pollStarted = clock.now(); boolean flushToDisk = lastSyncedAt + syncIntervalNanos <= pollStarted || state != NORMAL || syncRequested;
As of now we are lucky that in the current JDK implementations System.nanoTime() is much bigger than currentTimeMillis() but it is not guaranteed by a specification of the API. If nanoTime() < currentTimeMillis() then we can stuck without sync of commit log to disk.
So, we need to align the time sources and change the init logic to:
protected volatile long lastSyncedAt = preciseTime.now();
Attachments
Issue Links
- is duplicated by
-
CASSANDRA-20073 AbstractCommitLogService#lastSyncedAt initialized with currentTimeMillis() but later compared and updated with System.nanoTime()
- Resolved
- relates to
-
CASSANDRA-10202 simplify CommitLogSegmentManager
- Resolved
- links to