You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Todd Lipcon (Code Review)" <ge...@cloudera.org> on 2016/10/13 02:38:51 UTC

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Hello David Ribeiro Alves, Mike Percy,

I'd like you to do a code review.  Please visit

    http://gerrit.cloudera.org:8080/4709

to review the following change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................

consensus: move more logic from ReplicaState to RaftConsensus

ReplicaState currently has two main responsibilities:
* manage the set of pending transactions, including committing
  and aborting them. The main state here is the pending_txns_
  map.
* act as a wrapper to ConsensusMeta (stored as cmeta_).

These two items are relatively distinct. I drew a graph of the
dependencies between methods and members of ReplicaState[1] and it
became clear that most methods either pertained to one or the
other of these responsibilities, but not both. So, this patch seeks to
try to clean up the methods which were straddling the two
responsibilities as follows:

1. AbortOpsAfterUnlocked, AddPendingOperation, AdvanceCommittedIndexUnlocked

  These three are mainly focused around managing pending transactions,
  but were also taking care of setting the pending and committed Raft
  configuration in the case of configuration change operations.

  The patch moves the handling of configuration changes into
  RaftConsensus itself by using the existing "replicated callback" to
  perform the necessary work when the operation finishes, and by
  checking for config changes before adding pending operations.

4. CheckHasCommittedOpInCurrentTermUnlocked

  This one is used to check whether the last committed operation is in
  the current term. Recently the PeerMessageQueue became responsible for
  tracking the committed OpId, and already has the necessary state to
  provide the same functionality.

After the refactor, the class clearly shows two separate groups of
methods and members[2]. This will make it easier to maintain/understand
the code as well as open more opportunities for finer-grained locking by
having smaller classes with better-defined responsibilities.

I looped raft_consensus-itest 100 times with this patch and passed
100%[3].

NOTE: for the sake of the dependency graphs, I removed the state_
variable, ToString methods, and locking methods and left only the
"important" bits.

[1] http://i.imgur.com/fpyWwyM.png
[2] http://i.imgur.com/7K9Dc5J.png
[3] http://dist-test.cloudera.org/job?job_id=todd.1476324853.3445

Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
---
M src/kudu/consensus/consensus_queue.cc
M src/kudu/consensus/consensus_queue.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/consensus/raft_consensus.h
M src/kudu/consensus/raft_consensus_state.cc
M src/kudu/consensus/raft_consensus_state.h
M src/kudu/integration-tests/raft_consensus-itest.cc
7 files changed, 121 insertions(+), 98 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/09/4709/1
-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Mike Percy <mp...@apache.org>

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Mike Percy (Code Review)" <ge...@cloudera.org>.
Mike Percy has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 3: Code-Review+2

(1 comment)

http://gerrit.cloudera.org:8080/#/c/4709/3/src/kudu/consensus/raft_consensus.cc
File src/kudu/consensus/raft_consensus.cc:

Line 2063:   // NOTE: the ReplicaState lock is held here because this is triggered by
Thanks for this comment. I think it would also be helpful to mention this in the header file for ConsensusRound::NotifyReplicationFinished() and maybe also RaftConsensus::NonTxRoundReplicationFinished()


-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 3
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "David Ribeiro Alves (Code Review)" <ge...@cloudera.org>.
David Ribeiro Alves has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 5: Code-Review+2

-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 5
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "David Ribeiro Alves (Code Review)" <ge...@cloudera.org>.
David Ribeiro Alves has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 3:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/4709/3/src/kudu/consensus/raft_consensus.h
File src/kudu/consensus/raft_consensus.h:

PS3, Line 405: Handle
this wording is confusing. does this mean that it was replicated or committed? can you make the distinction in the name/commments?


PS3, Line 427: but first check for
             :   // and handle any consensus-related operations
what operations does this refer to? what is this "handling"?


http://gerrit.cloudera.org:8080/#/c/4709/3/src/kudu/consensus/raft_consensus_state.cc
File src/kudu/consensus/raft_consensus_state.cc:

Line 510: 
extra line


-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 3
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 1:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/4709/1/src/kudu/consensus/consensus_queue.h
File src/kudu/consensus/consensus_queue.h:

Line 65: // TODO Right now this class is able to track one outstanding operation
> warning: missing username/bug in TODO [google-readability-todo]
Done


PS1, Line 257: bool IsCommittedIndexInCurrentTerm() const;
> Is there an opportunity for the caller and the queue to disagree on what is
I don't think so because the current term is advanced only under the lock held by RaftConsensus, and this is called by RaftConsensus.


http://gerrit.cloudera.org:8080/#/c/4709/1/src/kudu/consensus/raft_consensus.cc
File src/kudu/consensus/raft_consensus.cc:

Line 618:     DCHECK(round->replicate_msg()->change_config_record().has_old_config());
> are these DCHECKs really necessary? old/new config are required fields of C
I just moved this code. I think the idea is that since this might be a proto that we created on our side, it hasn't necessarily been verified to be fully initialized yet (so the fact that the fields are required doesn't mean that they're necessarily set). I'm guessing this was added because of some bug where we were missing these fields in some code path.


-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Mike Percy, Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/4709

to look at the new patch set (#4).

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................

consensus: move more logic from ReplicaState to RaftConsensus

ReplicaState currently has two main responsibilities:
* manage the set of pending transactions, including committing
  and aborting them. The main state here is the pending_txns_
  map.
* act as a wrapper to ConsensusMeta (stored as cmeta_).

These two items are relatively distinct. I drew a graph of the
dependencies between methods and members of ReplicaState[1] and it
became clear that most methods either pertained to one or the
other of these responsibilities, but not both. So, this patch seeks to
try to clean up the methods which were straddling the two
responsibilities as follows:

1. AbortOpsAfterUnlocked, AddPendingOperation, AdvanceCommittedIndexUnlocked

  These three are mainly focused around managing pending transactions,
  but were also taking care of setting the pending and committed Raft
  configuration in the case of configuration change operations.

  The patch moves the handling of configuration changes into
  RaftConsensus itself by using the existing "replicated callback" to
  perform the necessary work when the operation finishes, and by
  checking for config changes before adding pending operations.

4. CheckHasCommittedOpInCurrentTermUnlocked

  This one is used to check whether the last committed operation is in
  the current term. Recently the PeerMessageQueue became responsible for
  tracking the committed OpId, and already has the necessary state to
  provide the same functionality.

After the refactor, the class clearly shows two separate groups of
methods and members[2]. This will make it easier to maintain/understand
the code as well as open more opportunities for finer-grained locking by
having smaller classes with better-defined responsibilities.

I looped raft_consensus-itest 100 times with this patch and passed
100%[3].

NOTE: for the sake of the dependency graphs, I removed the state_
variable, ToString methods, and locking methods and left only the
"important" bits.

[1] http://i.imgur.com/fpyWwyM.png
[2] http://i.imgur.com/7K9Dc5J.png
[3] http://dist-test.cloudera.org/job?job_id=todd.1476324853.3445

Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
---
M src/kudu/consensus/consensus_queue.cc
M src/kudu/consensus/consensus_queue.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/consensus/raft_consensus.h
M src/kudu/consensus/raft_consensus_state.cc
M src/kudu/consensus/raft_consensus_state.h
M src/kudu/integration-tests/raft_consensus-itest.cc
7 files changed, 128 insertions(+), 100 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/09/4709/4
-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 4
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 3:

this one still needs a re-review

-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 3
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has submitted this change and it was merged.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


consensus: move more logic from ReplicaState to RaftConsensus

ReplicaState currently has two main responsibilities:
* manage the set of pending transactions, including committing
  and aborting them. The main state here is the pending_txns_
  map.
* act as a wrapper to ConsensusMeta (stored as cmeta_).

These two items are relatively distinct. I drew a graph of the
dependencies between methods and members of ReplicaState[1] and it
became clear that most methods either pertained to one or the
other of these responsibilities, but not both. So, this patch seeks to
try to clean up the methods which were straddling the two
responsibilities as follows:

1. AbortOpsAfterUnlocked, AddPendingOperation, AdvanceCommittedIndexUnlocked

  These three are mainly focused around managing pending transactions,
  but were also taking care of setting the pending and committed Raft
  configuration in the case of configuration change operations.

  The patch moves the handling of configuration changes into
  RaftConsensus itself by using the existing "replicated callback" to
  perform the necessary work when the operation finishes, and by
  checking for config changes before adding pending operations.

4. CheckHasCommittedOpInCurrentTermUnlocked

  This one is used to check whether the last committed operation is in
  the current term. Recently the PeerMessageQueue became responsible for
  tracking the committed OpId, and already has the necessary state to
  provide the same functionality.

After the refactor, the class clearly shows two separate groups of
methods and members[2]. This will make it easier to maintain/understand
the code as well as open more opportunities for finer-grained locking by
having smaller classes with better-defined responsibilities.

I looped raft_consensus-itest 100 times with this patch and passed
100%[3].

NOTE: for the sake of the dependency graphs, I removed the state_
variable, ToString methods, and locking methods and left only the
"important" bits.

[1] http://i.imgur.com/fpyWwyM.png
[2] http://i.imgur.com/7K9Dc5J.png
[3] http://dist-test.cloudera.org/job?job_id=todd.1476324853.3445

Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Reviewed-on: http://gerrit.cloudera.org:8080/4709
Tested-by: Kudu Jenkins
Reviewed-by: David Ribeiro Alves <dr...@apache.org>
Reviewed-by: Mike Percy <mp...@apache.org>
---
M src/kudu/consensus/consensus_queue.cc
M src/kudu/consensus/consensus_queue.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/consensus/raft_consensus.h
M src/kudu/consensus/raft_consensus_state.cc
M src/kudu/consensus/raft_consensus_state.h
M src/kudu/integration-tests/raft_consensus-itest.cc
7 files changed, 129 insertions(+), 100 deletions(-)

Approvals:
  David Ribeiro Alves: Looks good to me, approved
  Mike Percy: Looks good to me, approved
  Kudu Jenkins: Verified



-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 6
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Mike Percy (Code Review)" <ge...@cloudera.org>.
Mike Percy has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 5: Code-Review+2

-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 5
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: No

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/4709

to look at the new patch set (#2).

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................

consensus: move more logic from ReplicaState to RaftConsensus

ReplicaState currently has two main responsibilities:
* manage the set of pending transactions, including committing
  and aborting them. The main state here is the pending_txns_
  map.
* act as a wrapper to ConsensusMeta (stored as cmeta_).

These two items are relatively distinct. I drew a graph of the
dependencies between methods and members of ReplicaState[1] and it
became clear that most methods either pertained to one or the
other of these responsibilities, but not both. So, this patch seeks to
try to clean up the methods which were straddling the two
responsibilities as follows:

1. AbortOpsAfterUnlocked, AddPendingOperation, AdvanceCommittedIndexUnlocked

  These three are mainly focused around managing pending transactions,
  but were also taking care of setting the pending and committed Raft
  configuration in the case of configuration change operations.

  The patch moves the handling of configuration changes into
  RaftConsensus itself by using the existing "replicated callback" to
  perform the necessary work when the operation finishes, and by
  checking for config changes before adding pending operations.

4. CheckHasCommittedOpInCurrentTermUnlocked

  This one is used to check whether the last committed operation is in
  the current term. Recently the PeerMessageQueue became responsible for
  tracking the committed OpId, and already has the necessary state to
  provide the same functionality.

After the refactor, the class clearly shows two separate groups of
methods and members[2]. This will make it easier to maintain/understand
the code as well as open more opportunities for finer-grained locking by
having smaller classes with better-defined responsibilities.

I looped raft_consensus-itest 100 times with this patch and passed
100%[3].

NOTE: for the sake of the dependency graphs, I removed the state_
variable, ToString methods, and locking methods and left only the
"important" bits.

[1] http://i.imgur.com/fpyWwyM.png
[2] http://i.imgur.com/7K9Dc5J.png
[3] http://dist-test.cloudera.org/job?job_id=todd.1476324853.3445

Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
---
M src/kudu/consensus/consensus_queue.cc
M src/kudu/consensus/consensus_queue.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/consensus/raft_consensus.h
M src/kudu/consensus/raft_consensus_state.cc
M src/kudu/consensus/raft_consensus_state.h
M src/kudu/integration-tests/raft_consensus-itest.cc
7 files changed, 122 insertions(+), 99 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/09/4709/2
-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Todd Lipcon has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 3:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/4709/3/src/kudu/consensus/raft_consensus.cc
File src/kudu/consensus/raft_consensus.cc:

Line 2063:   // NOTE: the ReplicaState lock is held here because this is triggered by
> Thanks for this comment. I think it would also be helpful to mention this i
would rather not add it in ConsensusRound::NotifyReplicationFinished, because other implementors (ie the tablet) shouldn't care about the fact that they are holding a consensus-internal lock. Will add to NonTxRoundReplicationFinished, though.


http://gerrit.cloudera.org:8080/#/c/4709/3/src/kudu/consensus/raft_consensus.h
File src/kudu/consensus/raft_consensus.h:

PS3, Line 405: Handle
> this wording is confusing. does this mean that it was replicated or committ
Done. Part of the confusion here is that, throughout consensus, we are a little fuzzy on the term 'replicated' vs 'committed'. Tried to clarify in the comments here.


PS3, Line 427: but first check for
             :   // and handle any consensus-related operations
> what operations does this refer to? what is this "handling"?
Done


http://gerrit.cloudera.org:8080/#/c/4709/3/src/kudu/consensus/raft_consensus_state.cc
File src/kudu/consensus/raft_consensus_state.cc:

Line 510: 
> extra line
Done


-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 3
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>
Gerrit-HasComments: Yes

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "Todd Lipcon (Code Review)" <ge...@cloudera.org>.
Hello Mike Percy, Kudu Jenkins,

I'd like you to reexamine a change.  Please visit

    http://gerrit.cloudera.org:8080/4709

to look at the new patch set (#5).

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................

consensus: move more logic from ReplicaState to RaftConsensus

ReplicaState currently has two main responsibilities:
* manage the set of pending transactions, including committing
  and aborting them. The main state here is the pending_txns_
  map.
* act as a wrapper to ConsensusMeta (stored as cmeta_).

These two items are relatively distinct. I drew a graph of the
dependencies between methods and members of ReplicaState[1] and it
became clear that most methods either pertained to one or the
other of these responsibilities, but not both. So, this patch seeks to
try to clean up the methods which were straddling the two
responsibilities as follows:

1. AbortOpsAfterUnlocked, AddPendingOperation, AdvanceCommittedIndexUnlocked

  These three are mainly focused around managing pending transactions,
  but were also taking care of setting the pending and committed Raft
  configuration in the case of configuration change operations.

  The patch moves the handling of configuration changes into
  RaftConsensus itself by using the existing "replicated callback" to
  perform the necessary work when the operation finishes, and by
  checking for config changes before adding pending operations.

4. CheckHasCommittedOpInCurrentTermUnlocked

  This one is used to check whether the last committed operation is in
  the current term. Recently the PeerMessageQueue became responsible for
  tracking the committed OpId, and already has the necessary state to
  provide the same functionality.

After the refactor, the class clearly shows two separate groups of
methods and members[2]. This will make it easier to maintain/understand
the code as well as open more opportunities for finer-grained locking by
having smaller classes with better-defined responsibilities.

I looped raft_consensus-itest 100 times with this patch and passed
100%[3].

NOTE: for the sake of the dependency graphs, I removed the state_
variable, ToString methods, and locking methods and left only the
"important" bits.

[1] http://i.imgur.com/fpyWwyM.png
[2] http://i.imgur.com/7K9Dc5J.png
[3] http://dist-test.cloudera.org/job?job_id=todd.1476324853.3445

Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
---
M src/kudu/consensus/consensus_queue.cc
M src/kudu/consensus/consensus_queue.h
M src/kudu/consensus/raft_consensus.cc
M src/kudu/consensus/raft_consensus.h
M src/kudu/consensus/raft_consensus_state.cc
M src/kudu/consensus/raft_consensus_state.h
M src/kudu/integration-tests/raft_consensus-itest.cc
7 files changed, 129 insertions(+), 100 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/09/4709/5
-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 5
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <to...@apache.org>

[kudu-CR] consensus: move more logic from ReplicaState to RaftConsensus

Posted by "David Ribeiro Alves (Code Review)" <ge...@cloudera.org>.
David Ribeiro Alves has posted comments on this change.

Change subject: consensus: move more logic from ReplicaState to RaftConsensus
......................................................................


Patch Set 1:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/4709/1/src/kudu/consensus/consensus_queue.h
File src/kudu/consensus/consensus_queue.h:

PS1, Line 257: bool IsCommittedIndexInCurrentTerm() const;
Is there an opportunity for the caller and the queue to disagree on what is the "current" term?


http://gerrit.cloudera.org:8080/#/c/4709/1/src/kudu/consensus/raft_consensus.cc
File src/kudu/consensus/raft_consensus.cc:

Line 618:     DCHECK(round->replicate_msg()->change_config_record().has_old_config());
are these DCHECKs really necessary? old/new config are required fields of ChangeConfigRecordPB. We could likely replace this with just a DCHECK that the old/new config have the op id set below.


-- 
To view, visit http://gerrit.cloudera.org:8080/4709
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I0f377ebb132f3f58f984605197831f41198d78c5
Gerrit-PatchSet: 1
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Todd Lipcon <to...@apache.org>
Gerrit-Reviewer: David Ribeiro Alves <dr...@apache.org>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Mike Percy <mp...@apache.org>
Gerrit-Reviewer: Tidy Bot
Gerrit-HasComments: Yes