[ 
https://issues.apache.org/jira/browse/CASSANDRA-20074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17897596#comment-17897596
 ] 

Dmitry Konstantinov edited comment on CASSANDRA-20074 at 11/12/24 3:01 PM:
---------------------------------------------------------------------------

The change when the issue appeared: 
https://github.com/netudima/cassandra/commit/e8907c16abcd84021a39cdaac79b609fcc64a43c#diff-527474f3bee4faf0caab725524e5bbf6523295c40febaa81fcb2b7310a5a9bee
 
CASSANDRA-10202 (3.10)


was (Author: dnk):
The change when the issue appeared: 
https://github.com/netudima/cassandra/commit/e8907c16abcd84021a39cdaac79b609fcc64a43c#diff-527474f3bee4faf0caab725524e5bbf6523295c40febaa81fcb2b7310a5a9bee
 

> 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
>            Priority: Low
>          Time Spent: 10m
>  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]

Reply via email to