[
https://issues.apache.org/jira/browse/HBASE-20981?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jack Bearden updated HBASE-20981:
---------------------------------
Assignee: Jack Bearden
Attachment: HBASE-20981.branch-2.001.patch
Status: Patch Available (was: Open)
Hi [~stack]. From what I can tell, it looks like this use-case may have been
missed due to no testing around the stateCounter bool when rollback() is called
on StateMachineProcedure. I uploaded patch #1 in an effort to improve on this.
* Scope of changes
** Moved decrementing stateCount out of the try block and into finally block
instead.
** Added two tests. One test that checks stateCount for normal rollbacks and
one check for stateCount in a rollback() that throws exceptions.
* Places this patch could improve
** I had to change isEofState() and stateCount from private to protected so I
was able to override it in the test class. I do not like that I had to
sacrifice the encapsulation of the class for the test behavior. Maybe
implementing a getter and setter for stateCount would be the better approach
here?
** Code duplication for a new TestSMProcedure class that had the rollback()
function with an exception in it. I was hoping to not impact the other tests,
so I duplicated code to get the behavior for rollback() that I wanted. There
may be a better way to do this.
> Rollback stateCount accounting thrown-off when exception out of rollbackState
> -----------------------------------------------------------------------------
>
> Key: HBASE-20981
> URL: https://issues.apache.org/jira/browse/HBASE-20981
> Project: HBase
> Issue Type: Bug
> Components: amv2
> Affects Versions: 2.0.1
> Reporter: stack
> Assignee: Jack Bearden
> Priority: Major
> Fix For: 2.0.2
>
> Attachments: HBASE-20981.branch-2.001.patch
>
>
> Found by might [~allan163] over in HBASE-20893. Quoting Allan:
> {code}
> But, there is truly a bug here,
> @Override
> protected void rollback(final TEnvironment env)
> throws IOException, InterruptedException {
> if (isEofState()) stateCount--;
> try {
> updateTimestamp();
> rollbackState(env, getCurrentState());
> stateCount--;
> } finally {
> updateTimestamp();
> }
> }
> We need to decrease the stateCount when rolling back, so we can rollback for
> the previous state correctly. But. since a exception is thrown, the decrease
> for stateCount never happen. So ProcedureExecutor will continue to rollback
> for only one state(the one throw a exception) until the end of the execution
> stack.
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)