protected void validate() { ActiveTransactionsRecord lastSeenCommitted = helpCommitAll(); // if (isSnapshotValidationWorthIt(lastSeenCommitted)) { // this validates up to the last seen committed at least snapshotValidation(lastSeenCommitted.transactionNumber); validateCommitAndEnqueue(lastSeenCommitted); // } else { // validateCommitAndEnqueue(this.activeTxRecord); // } }
/** * Validates this read-set against all active transaction records more recent that the one * <code>lastChecked</code>. * * @return The last successfully validated ActiveTransactionsRecord * @throws CommitException if the validation fails */ protected ActiveTransactionsRecord validate(ActiveTransactionsRecord startCheck) { ActiveTransactionsRecord lastChecked = startCheck; ActiveTransactionsRecord recordToCheck = lastChecked.getNext(); while (recordToCheck != null) { lastChecked = recordToCheck; recordToCheck = recordToCheck.getNext(); } if (lastChecked != startCheck) { helpCommitAll(); snapshotValidation(lastChecked.transactionNumber); } return lastChecked; }
/** * Enqueue a valid commit (just after the record lastCheck). If enqueue fails then, revalidate, upgrade the transaction and retry to enqueue. * * @param lastCheck The last record up to where validation succeeded. * @param writeSet The writeSet of this commit. * @return */ /* This code was extracted from validateCommitAndEnqueue, to enable overriding it in subclasses that wish to reuse the remainder of the algorithm coded in validateCommitAndEnqueue. */ protected void enqueueValidCommit(ActiveTransactionsRecord lastCheck, WriteSet writeSet) { ProcessPerTxBoxesTransaction commitTx; while (!lastCheck.trySetNext(getCommitTxRecord())) { // Failed enqueue, at least some other transaction succeeded in the meantime lastCheck = helpCommitAll(); snapshotValidation(lastCheck.transactionNumber); // Re-execute the perTxBoxes speculatively. They are supposed to be a point of contention, thus // any validation to check if previous speculative reads are still up-to-date should most of the time // lead to the conclusion that they are not. This way we avoid registering those reads and skip the validation. commitTx = speculatePerTxBoxes(lastCheck.transactionNumber); writeSet.addPerTxBoxesWrites(commitTx.specWriteSet); assignCommitRecord(lastCheck.transactionNumber + 1, writeSet); } }