private void beginCommitAsyncTest(CommitData cd) { CommitStep firstStep = new LockPrimaryStep(); firstStep.andThen(new LockOtherStep()).andThen(new CommittedTestStep()); firstStep.compose(cd).exceptionally(throwable -> { setFailed(cd, throwable); return null; }); }
@Override CompletableFuture<Void> getFailureOp(CommitData cd) { // TODO can this be simplified by pushing some code to the superclass? return CompletableFuture.supplyAsync(() -> { final ConditionalMutation pcm = Iterables.getOnlyElement(createMutations(cd)); cd.addPrimaryToRejected(); getStats().setRejected(cd.getRejected()); // TODO do async try { checkForOrphanedLocks(cd); } catch (Exception e) { throw new CompletionException(e); } if (checkForAckCollision(pcm)) { cd.commitObserver.alreadyAcknowledged(); } else { cd.commitObserver.commitFailed(cd.getShortCollisionMessage()); } return null; }, env.getSharedResources().getSyncCommitExecutor()); }
private void beginCommitAsync(CommitData cd) { // Notification are written between GetCommitStampStep and CommitPrimaryStep for the following // reasons : // * At this point all columns are locked, this guarantees that anything triggering as a // result of this transaction will see all of this transactions changes. // * The transaction is not yet committed. If the process dies at this point whatever // was running this transaction should rerun and recreate all of the notifications. // The next transactions will rerun because this transaction will have to be rolled back. // * If notifications are written in the 2nd phase of commit, then when the 2nd phase // partially succeeds notifications may never be written. Because in the case of failure // notifications would not be written until a column is read and it may never be read. // See https://github.com/fluo-io/fluo/issues/642 // // Its very important the notifications which trigger an observer are deleted after the 2nd // phase of commit finishes. CommitStep firstStep = new LockPrimaryStep(); firstStep.andThen(new LockOtherStep()).andThen(new GetCommitStampStep()) .andThen(new WriteNotificationsStep()).andThen(new CommitPrimaryStep()) .andThen(new DeleteLocksStep()).andThen(new FinishCommitStep()); firstStep.compose(cd).exceptionally(throwable -> { setFailed(cd, throwable); return null; }); }
private void beginCommitAsync(CommitData cd) { // Notification are written between GetCommitStampStep and CommitPrimaryStep for the following // reasons : // * At this point all columns are locked, this guarantees that anything triggering as a // result of this transaction will see all of this transactions changes. // * The transaction is not yet committed. If the process dies at this point whatever // was running this transaction should rerun and recreate all of the notifications. // The next transactions will rerun because this transaction will have to be rolled back. // * If notifications are written in the 2nd phase of commit, then when the 2nd phase // partially succeeds notifications may never be written. Because in the case of failure // notifications would not be written until a column is read and it may never be read. // See https://github.com/fluo-io/fluo/issues/642 // // Its very important the notifications which trigger an observer are deleted after the 2nd // phase of commit finishes. CommitStep firstStep = new LockPrimaryStep(); firstStep.andThen(new LockOtherStep()).andThen(new GetCommitStampStep()) .andThen(new WriteNotificationsStep()).andThen(new CommitPrimaryStep()) .andThen(new DeleteLocksStep()).andThen(new FinishCommitStep()); firstStep.compose(cd).exceptionally(throwable -> { setFailed(cd, throwable); return null; }); }
@Override CompletableFuture<Void> getFailureOp(CommitData cd) { // TODO can this be simplified by pushing some code to the superclass? return CompletableFuture.supplyAsync(() -> { final ConditionalMutation pcm = Iterables.getOnlyElement(createMutations(cd)); cd.addPrimaryToRejected(); getStats().setRejected(cd.getRejected()); // TODO do async try { checkForOrphanedLocks(cd); } catch (Exception e) { throw new CompletionException(e); } if (checkForAckCollision(pcm)) { cd.commitObserver.alreadyAcknowledged(); } else { cd.commitObserver.commitFailed(cd.getShortCollisionMessage()); } return null; }, env.getSharedResources().getSyncCommitExecutor()); }
private void beginCommitAsyncTest(CommitData cd) { CommitStep firstStep = new LockPrimaryStep(); firstStep.andThen(new LockOtherStep()).andThen(new CommittedTestStep()); firstStep.compose(cd).exceptionally(throwable -> { setFailed(cd, throwable); return null; }); }