You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@omid.apache.org by yo...@apache.org on 2018/11/13 10:15:54 UTC
[02/50] [abbrv] incubator-omid git commit: [OMID-72] bug fix,
accessed tables should be sent to transaction manager also for
conflict free writes. This is because fences should also force conflict free
transactions to abort.
[OMID-72] bug fix, accessed tables should be sent to transaction manager also for conflict free writes. This is because fences should also force conflict free transactions to abort.
Project: http://git-wip-us.apache.org/repos/asf/incubator-omid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-omid/commit/ce5c68c0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-omid/tree/ce5c68c0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-omid/diff/ce5c68c0
Branch: refs/heads/1.0.0
Commit: ce5c68c02cb620c205655b7eacb29463d5cbd935
Parents: 5cb091c
Author: Ohad Shacham <oh...@yahoo-inc.com>
Authored: Tue Jun 5 16:28:21 2018 +0300
Committer: Yonatan Gottesman <yo...@gmail.com>
Committed: Tue Nov 13 10:03:10 2018 +0200
----------------------------------------------------------------------
.../transaction/TestHBaseTransactionManager.java | 4 ++--
.../omid/transaction/TestTransactionCleanup.java | 2 +-
.../transaction/AbstractTransactionManager.java | 2 +-
.../org/apache/omid/tso/client/MockTSOClient.java | 5 +++++
.../java/org/apache/omid/tso/client/TSOClient.java | 13 +++++++++++++
.../org/apache/omid/tso/client/TSOProtocol.java | 16 ++++++++++++++++
.../apache/omid/tso/client/TestMockTSOClient.java | 10 ++++++----
7 files changed, 44 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/ce5c68c0/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
index 347c4ce..51ec0c1 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestHBaseTransactionManager.java
@@ -83,7 +83,7 @@ public class TestHBaseTransactionManager extends OmidTestBase {
txTable.put(tx1, put);
tm.commit(tx1);
- verify(tsoClient, times(EXPECTED_INVOCATIONS_FOR_COMMIT)).commit(anyLong(), anySetOf(HBaseCellId.class));
+ verify(tsoClient, times(EXPECTED_INVOCATIONS_FOR_COMMIT)).commit(anyLong(), anySetOf(HBaseCellId.class), anySetOf(HBaseCellId.class));
// Create a read-only tx and verify that commit has not been invoked again in the TSOClient
AbstractTransaction readOnlyTx = (AbstractTransaction) tm.begin();
@@ -93,7 +93,7 @@ public class TestHBaseTransactionManager extends OmidTestBase {
assertTrue(readOnlyTx.getWriteSet().isEmpty());
tm.commit(readOnlyTx);
- verify(tsoClient, times(EXPECTED_INVOCATIONS_FOR_COMMIT)).commit(anyLong(), anySetOf(HBaseCellId.class));
+ verify(tsoClient, times(EXPECTED_INVOCATIONS_FOR_COMMIT)).commit(anyLong(), anySetOf(HBaseCellId.class), anySetOf(HBaseCellId.class));
assertEquals(readOnlyTx.getStatus(), Transaction.Status.COMMITTED_RO);
}
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/ce5c68c0/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
index 543e0c2..2060bc3 100644
--- a/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
+++ b/hbase-client/src/test/java/org/apache/omid/transaction/TestTransactionCleanup.java
@@ -77,7 +77,7 @@ public class TestTransactionCleanup extends OmidTestBase {
.when(mockedTSOClient).getNewStartTimestamp();
doReturn(abortingFF)
- .when(mockedTSOClient).commit(eq(START_TS), anySetOf(HBaseCellId.class));
+ .when(mockedTSOClient).commit(eq(START_TS), anySetOf(HBaseCellId.class), anySetOf(HBaseCellId.class));
try (TransactionManager tm = newTransactionManager(context, mockedTSOClient);
TTable txTable = new TTable(hbaseConf, TEST_TABLE)) {
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/ce5c68c0/transaction-client/src/main/java/org/apache/omid/transaction/AbstractTransactionManager.java
----------------------------------------------------------------------
diff --git a/transaction-client/src/main/java/org/apache/omid/transaction/AbstractTransactionManager.java b/transaction-client/src/main/java/org/apache/omid/transaction/AbstractTransactionManager.java
index d9d9914..0323e26 100644
--- a/transaction-client/src/main/java/org/apache/omid/transaction/AbstractTransactionManager.java
+++ b/transaction-client/src/main/java/org/apache/omid/transaction/AbstractTransactionManager.java
@@ -360,7 +360,7 @@ public abstract class AbstractTransactionManager implements TransactionManager {
try {
- long commitTs = tsoClient.commit(tx.getStartTimestamp(), tx.getWriteSet()).get();
+ long commitTs = tsoClient.commit(tx.getStartTimestamp(), tx.getWriteSet(), tx.getConflictFreeWriteSet()).get();
certifyCommitForTx(tx, commitTs);
updateShadowCellsAndRemoveCommitTableEntry(tx, postCommitter);
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/ce5c68c0/transaction-client/src/main/java/org/apache/omid/tso/client/MockTSOClient.java
----------------------------------------------------------------------
diff --git a/transaction-client/src/main/java/org/apache/omid/tso/client/MockTSOClient.java b/transaction-client/src/main/java/org/apache/omid/tso/client/MockTSOClient.java
index 543e9ea..ed99c8b 100644
--- a/transaction-client/src/main/java/org/apache/omid/tso/client/MockTSOClient.java
+++ b/transaction-client/src/main/java/org/apache/omid/tso/client/MockTSOClient.java
@@ -106,6 +106,11 @@ public class MockTSOClient implements TSOProtocol {
}
@Override
+ public TSOFuture<Long> commit(long transactionId, Set<? extends CellId> cells, Set<? extends CellId> conflictFreeWriteSet) {
+ return commit(transactionId, cells);
+ }
+
+ @Override
public TSOFuture<Long> commit(long transactionId, Set<? extends CellId> cells) {
synchronized (conflictMap) {
SettableFuture<Long> f = SettableFuture.create();
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/ce5c68c0/transaction-client/src/main/java/org/apache/omid/tso/client/TSOClient.java
----------------------------------------------------------------------
diff --git a/transaction-client/src/main/java/org/apache/omid/tso/client/TSOClient.java b/transaction-client/src/main/java/org/apache/omid/tso/client/TSOClient.java
index 8fe3f87..ec4ce8d 100644
--- a/transaction-client/src/main/java/org/apache/omid/tso/client/TSOClient.java
+++ b/transaction-client/src/main/java/org/apache/omid/tso/client/TSOClient.java
@@ -201,6 +201,14 @@ public class TSOClient implements TSOProtocol, NodeCacheListener {
*/
@Override
public TSOFuture<Long> commit(long transactionId, Set<? extends CellId> cells) {
+ return commit(transactionId, cells, new HashSet<CellId>());
+ }
+
+ /**
+ * @see TSOProtocol#commit(long, Set, Set)
+ */
+ @Override
+ public TSOFuture<Long> commit(long transactionId, Set<? extends CellId> cells, Set<? extends CellId> conflictFreeWriteSet) {
TSOProto.Request.Builder builder = TSOProto.Request.newBuilder();
TSOProto.CommitRequest.Builder commitbuilder = TSOProto.CommitRequest.newBuilder();
commitbuilder.setStartTimestamp(transactionId);
@@ -229,6 +237,11 @@ public class TSOClient implements TSOProtocol, NodeCacheListener {
commitbuilder.addCellId(id);
tableIDs.add(cell.getTableId());
}
+
+ for (CellId cell : conflictFreeWriteSet) {
+ tableIDs.add(cell.getTableId());
+ }
+
commitbuilder.addAllTableId(tableIDs);
tableIDs.clear();
builder.setCommitRequest(commitbuilder.build());
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/ce5c68c0/transaction-client/src/main/java/org/apache/omid/tso/client/TSOProtocol.java
----------------------------------------------------------------------
diff --git a/transaction-client/src/main/java/org/apache/omid/tso/client/TSOProtocol.java b/transaction-client/src/main/java/org/apache/omid/tso/client/TSOProtocol.java
index e3810b9..dd72cf3 100644
--- a/transaction-client/src/main/java/org/apache/omid/tso/client/TSOProtocol.java
+++ b/transaction-client/src/main/java/org/apache/omid/tso/client/TSOProtocol.java
@@ -58,6 +58,22 @@ public interface TSOProtocol {
TSOFuture<Long> commit(long transactionId, Set<? extends CellId> writeSet);
/**
+ * Returns the result of the conflict detection made on the server-side for the specified transaction
+ * @param transactionId
+ * the transaction to check for conflicts
+ * @param writeSet
+ * the writeSet of the transaction, which includes all the modified cells
+ * @param conflictFreeWriteSet
+ * the conflict free writeSet of the transaction, needed only for table access information.
+ * @return the commit timestamp as a future if the transaction was committed. If the transaction was aborted due
+ * to conflicts with a concurrent transaction, the future will include an AbortException. If an error was detected,
+ * the future will contain a corresponding protocol exception
+ * see org.apache.omid.tso.TimestampOracle
+ * see org.apache.omid.tso.TSOServer
+ */
+ TSOFuture<Long> commit(long transactionId, Set<? extends CellId> writeSet, Set<? extends CellId> conflictFreeWriteSet);
+
+ /**
* Returns a new fence timestamp assigned by on the server-side
* @param tableId
* the table to create fence for.
http://git-wip-us.apache.org/repos/asf/incubator-omid/blob/ce5c68c0/transaction-client/src/test/java/org/apache/omid/tso/client/TestMockTSOClient.java
----------------------------------------------------------------------
diff --git a/transaction-client/src/test/java/org/apache/omid/tso/client/TestMockTSOClient.java b/transaction-client/src/test/java/org/apache/omid/tso/client/TestMockTSOClient.java
index 054eb65..b68b552 100644
--- a/transaction-client/src/test/java/org/apache/omid/tso/client/TestMockTSOClient.java
+++ b/transaction-client/src/test/java/org/apache/omid/tso/client/TestMockTSOClient.java
@@ -18,11 +18,13 @@
package org.apache.omid.tso.client;
import com.google.common.collect.Sets;
+
import org.apache.omid.committable.CommitTable;
import org.apache.omid.committable.InMemoryCommitTable;
import org.apache.omid.tso.util.DummyCellIdImpl;
import org.testng.annotations.Test;
+import java.util.HashSet;
import java.util.concurrent.ExecutionException;
import static org.testng.Assert.assertEquals;
@@ -42,10 +44,10 @@ public class TestMockTSOClient {
long tr1 = client.getNewStartTimestamp().get();
long tr2 = client.getNewStartTimestamp().get();
- client.commit(tr1, Sets.newHashSet(c1)).get();
+ client.commit(tr1, Sets.newHashSet(c1), new HashSet<CellId>()).get();
try {
- client.commit(tr2, Sets.newHashSet(c1, c2)).get();
+ client.commit(tr2, Sets.newHashSet(c1, c2), new HashSet<CellId>()).get();
fail("Shouldn't have committed");
} catch (ExecutionException ee) {
assertEquals(ee.getCause().getClass(), AbortException.class, "Should have aborted");
@@ -59,12 +61,12 @@ public class TestMockTSOClient {
CommitTable.Client commitTableClient = commitTable.getClient();
long tr1 = client.getNewStartTimestamp().get();
- client.commit(tr1, Sets.newHashSet(c1)).get();
+ client.commit(tr1, Sets.newHashSet(c1), new HashSet<CellId>()).get();
long initWatermark = commitTableClient.readLowWatermark().get();
long tr2 = client.getNewStartTimestamp().get();
- client.commit(tr2, Sets.newHashSet(c1)).get();
+ client.commit(tr2, Sets.newHashSet(c1), new HashSet<CellId>()).get();
long newWatermark = commitTableClient.readLowWatermark().get();
assertTrue(newWatermark > initWatermark, "new low watermark should be bigger");