You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Attila Doroszlai (Jira)" <ji...@apache.org> on 2023/12/22 13:08:00 UTC

[jira] [Resolved] (HDDS-9984) RatisSnapshotInfo is synchronized incorrectly

     [ https://issues.apache.org/jira/browse/HDDS-9984?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Attila Doroszlai resolved HDDS-9984.
------------------------------------
    Fix Version/s: 1.5.0
       Resolution: Fixed

> RatisSnapshotInfo is synchronized incorrectly
> ---------------------------------------------
>
>                 Key: HDDS-9984
>                 URL: https://issues.apache.org/jira/browse/HDDS-9984
>             Project: Apache Ozone
>          Issue Type: Bug
>          Components: OM, SCM
>            Reporter: Tsz-wo Sze
>            Assignee: Tsz-wo Sze
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.5.0
>
>
> Both term and snapshotIndex are volatile.  It is possible to get inconsistent return values from getTermIndex() and toString() while updateTermIndex(..) is running in the middle.
> {code}
>   private volatile long term = 0;
>   private volatile long snapshotIndex = -1;
>   ...
>   public void updateTermIndex(long newTerm, long newIndex) {
>     this.term = newTerm;
>     this.snapshotIndex = newIndex;
>   }
>   ...
>   @Override
>   public TermIndex getTermIndex() {
>     return TermIndex.valueOf(term, snapshotIndex);
>   }
>   ...
>   @Override
>   public String toString() {
>     StringBuilder stringBuilder = new StringBuilder();
>     stringBuilder.append(term);
>     stringBuilder.append(TRANSACTION_INFO_SPLIT_KEY);
>     stringBuilder.append(snapshotIndex);
>     return stringBuilder.toString();
>   }
> {code}
> Also, RatisSnapshotInfo is not useful since it mostly duplicates the code in TransactionInfo.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org