[
https://issues.apache.org/jira/browse/CASSANDRA-20074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17898008#comment-17898008
]
Dmitry Konstantinov edited comment on CASSANDRA-20074 at 11/13/24 5:51 PM:
---------------------------------------------------------------------------
5.0: https://github.com/apache/cassandra/pull/3681
trunk: https://github.com/apache/cassandra/pull/3682
was (Author: dnk):
5.0: https://github.com/apache/cassandra/pull/3681
> AbstractCommitLogService#lastSyncedAt initialized with currentTimeMillis()
> but later compared and updated with System.nanoTime()
> ---------------------------------------------------------------------------------------------------------------------------------
>
> Key: CASSANDRA-20074
> URL: https://issues.apache.org/jira/browse/CASSANDRA-20074
> Project: Cassandra
> Issue Type: Bug
> Components: Local/Commit Log
> Reporter: Dmitry Konstantinov
> Assignee: Dmitry Konstantinov
> Priority: Low
> Fix For: 4.0.x, 4.1.x, 5.0.x, 5.x
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> Within org.apache.cassandra.db.commitlog.AbstractCommitLogService
> we use System.currentMillis()-based time to initialize lastSyncedAt field:
> {code:java}
> protected volatile long lastSyncedAt = currentTimeMillis();{code}
> but later we use clock.now() = System.nanoTime() to compare and update the
> field value:
> {code:java}
> long pollStarted = clock.now();
> boolean flushToDisk = lastSyncedAt + syncIntervalNanos <= pollStarted ||
> state != NORMAL || syncRequested; {code}
> 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:
> {code:java}
> protected volatile long lastSyncedAt = preciseTime.now();{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]