Skip to content

Commit

Permalink
[NO ISSUE][TX] Fix WAIT_LOG Reading
Browse files Browse the repository at this point in the history
- user model changes: no
- storage format changes: no
- interface changes: no

Details:
- Fix WAIT_LOG reading.
- Add test case.

Change-Id: I6a8b75152466f96a4b00cc6f2d25582ba65e6013
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2466
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
  • Loading branch information
mblow authored and mhubail committed Mar 9, 2018
1 parent 2e4f34e commit 5cc4e7a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.asterix.test.txn;

import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

Expand All @@ -36,13 +37,15 @@
import org.apache.asterix.common.transactions.ITransactionContext;
import org.apache.asterix.common.transactions.ITransactionManager;
import org.apache.asterix.common.transactions.LogRecord;
import org.apache.asterix.common.transactions.LogSource;
import org.apache.asterix.common.transactions.LogType;
import org.apache.asterix.common.transactions.TransactionOptions;
import org.apache.asterix.common.transactions.TxnId;
import org.apache.asterix.common.utils.TransactionUtil;
import org.apache.asterix.metadata.entities.Dataset;
import org.apache.asterix.test.common.TestTupleReference;
import org.apache.asterix.transaction.management.service.logging.LogManager;
import org.apache.asterix.transaction.management.service.transaction.TransactionContextFactory;
import org.apache.asterix.transaction.management.service.transaction.TransactionManagementConstants.LockManagerConstants;
import org.apache.hyracks.storage.am.common.impls.NoOpOperationCallback;
import org.apache.hyracks.storage.am.lsm.common.api.ILSMIndex;
Expand Down Expand Up @@ -164,6 +167,27 @@ public void interruptedLogFileSwitch() throws Exception {
interruptedLogPageSwitch();
}

@Test
public void waitLogTest() throws Exception {
final INcApplicationContext ncAppCtx = (INcApplicationContext) integrationUtil.ncs[0].getApplicationContext();
LogRecord logRecord = new LogRecord();
final long txnId = 1;
logRecord.setTxnCtx(TransactionContextFactory.create(new TxnId(txnId),
new TransactionOptions(ITransactionManager.AtomicityLevel.ENTITY_LEVEL)));
logRecord.setLogSource(LogSource.LOCAL);
logRecord.setLogType(LogType.WAIT);
logRecord.setTxnId(txnId);
logRecord.isFlushed(false);
logRecord.computeAndSetLogSize();
Thread transactor = new Thread(() -> {
final LogManager logManager = (LogManager) ncAppCtx.getTransactionSubsystem().getLogManager();
logManager.log(logRecord);
});
transactor.start();
transactor.join(TimeUnit.SECONDS.toMillis(30));
Assert.assertTrue(logRecord.isFlushed());
}

private static ITransactionContext beingTransaction(INcApplicationContext ncAppCtx, ILSMIndex index,
long resourceId) {
final TxnId txnId = new TxnId(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,6 @@ private RecordReadStatus doReadLogRecord(ByteBuffer buffer) {
computeAndSetLogSize();
break;
case LogType.WAIT:
if (buffer.remaining() < ILogRecord.DS_LEN) {
return RecordReadStatus.TRUNCATED;
}
datasetId = buffer.getInt();
resourceId = 0l;
computeAndSetLogSize();
break;
case LogType.JOB_COMMIT:
Expand Down

0 comments on commit 5cc4e7a

Please sign in to comment.