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

Tsz-wo Sze reassigned HDDS-9984:
--------------------------------

       Assignee: Tsz-wo Sze
    Description: 
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.


  was:RatisSnapshotInfo is not useful since it mostly duplicates the code in 
TransactionInfo.

     Issue Type: Bug  (was: Improvement)
        Summary: RatisSnapshotInfo is synchronized incorrectly  (was: Remove 
RatisSnapshotInfo)

> 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
>
> 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to