You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Aravindan Vijayan (Jira)" <ji...@apache.org> on 2020/12/02 22:05:00 UTC

[jira] [Created] (RATIS-1194) SegmentedRaftLog syncWithSnapshot should not create a new open segment.

Aravindan Vijayan created RATIS-1194:
----------------------------------------

             Summary: SegmentedRaftLog syncWithSnapshot should not create a new open segment.
                 Key: RATIS-1194
                 URL: https://issues.apache.org/jira/browse/RATIS-1194
             Project: Ratis
          Issue Type: Bug
    Affects Versions: 1.1.0
            Reporter: Aravindan Vijayan
            Assignee: Aravindan Vijayan


In SegmentedRaftLog#syncWithSnapshot, if the snapshot index is the last open segment index, then the open segment is finalized and closed (which releases the SegmentedRaftLogOutputStream). In the next step, while rolling the open segment in the cache, a new open segment is created. However, the output stream has already been closed. This causes the peer to terminate when a transaction comes in after the syncWithSnapshot call.

{code}
    @Override
    public void execute() throws IOException {
      if (stateMachineDataPolicy.isSync() && stateMachineFuture != null) {
        stateMachineDataPolicy.getFromFuture(stateMachineFuture, () -> this + "-writeStateMachineData");
      }

      raftLogMetrics.onRaftLogAppendEntry();
      raftLogMetrics.onRaftLogAppendEntry();
      Preconditions.assertTrue(out != null);
      Preconditions.assertTrue(lastWrittenIndex + 1 == entry.getIndex(),
{code}

Instead of creating a new open segment here, we should let any new transaction coming in to the system create a new open segment through the StartOpenSegment call which re-initializes the output stream.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)