errose28 commented on a change in pull request #1613:
URL: https://github.com/apache/ozone/pull/1613#discussion_r536442503
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/upgrade/OMPrepareRequest.java
##########
@@ -166,36 +166,29 @@ private static void waitForDoubleBufferFlush(
*/
public static long takeSnapshotAndPurgeLogs(RaftServerImpl impl)
throws IOException {
-
StateMachine stateMachine = impl.getStateMachine();
long snapshotIndex = stateMachine.takeSnapshot();
+ RaftLog raftLog = impl.getState().getLog();
+ long raftLogIndex = raftLog.getLastEntryTermIndex().getIndex();
- // If the snapshot indices from Ratis and the state machine do not match,
- // the exception is propagated, resulting in an error response to the
- // client. They can retry the prepare request.
- if (snapshotIndex != stateMachine.getLastAppliedTermIndex().getIndex()) {
- throw new IOException("Index from Snapshot does not match last applied "
+
- "Index");
+ if (snapshotIndex != raftLogIndex) {
Review comment:
Right. The gate to stop further write transactions will be added in a
later Jira. This is added in anticipation of that feature. Current testing
acknowledges that the gate does not exist by not submitting requests after
prepare. Basically this whole pull request will have issues under a real use
case without the gate, which is why this is part of a larger feature off of the
master branch.
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/upgrade/OMPrepareRequest.java
##########
@@ -137,16 +137,21 @@ private static void waitForDoubleBufferFlush(
// If no transactions have been persisted to the DB, transaction info
// will be null, not zero, causing a null pointer exception within
// ozoneManager#getRatisSnaphotIndex.
- // Get the transaction directly instead.
- OMTransactionInfo txnInfo = ozoneManager.getMetadataManager()
+ // Get the transaction directly instead to handle the case when it is
+ // null.
+ OMTransactionInfo dbTxnInfo = ozoneManager.getMetadataManager()
.getTransactionInfoTable().get(TRANSACTION_INFO_KEY);
- if (txnInfo == null) {
- success = (txnLogIndex == 0);
+ if (dbTxnInfo == null) {
+ // If there are no transactions in the DB, we are prepared to log
Review comment:
Yes, when it is flushed. But this is the method that is waiting for the
flush. The flush has not necessarily completed by the first run of this loop.
It is possible that when prepare is the first transaction to the DB, this
method call happens before its flush completes, and on the first (few)
iterations of the loop, the transaction info table is empty and dbTxnInfo will
be null. Once the flush completes, dbTxnInfo will no longer be null on later
loop iterations.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]