You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by wf...@apache.org on 2016/01/21 23:30:33 UTC

aurora git commit: Enable READ COMMITTED transaction isolation.

Repository: aurora
Updated Branches:
  refs/heads/master 8d3fb2413 -> b2cc604a6


Enable READ COMMITTED transaction isolation.

Bugs closed: AURORA-1580

Reviewed at https://reviews.apache.org/r/42613/


Project: http://git-wip-us.apache.org/repos/asf/aurora/repo
Commit: http://git-wip-us.apache.org/repos/asf/aurora/commit/b2cc604a
Tree: http://git-wip-us.apache.org/repos/asf/aurora/tree/b2cc604a
Diff: http://git-wip-us.apache.org/repos/asf/aurora/diff/b2cc604a

Branch: refs/heads/master
Commit: b2cc604a66c2d6b978f35dace332581bce4abfd7
Parents: 8d3fb24
Author: Bill Farner <wf...@apache.org>
Authored: Thu Jan 21 14:30:28 2016 -0800
Committer: Bill Farner <wf...@apache.org>
Committed: Thu Jan 21 14:30:28 2016 -0800

----------------------------------------------------------------------
 .../aurora/scheduler/storage/db/DbModule.java   |  9 +++----
 .../aurora/scheduler/storage/db/TaskMapper.xml  |  8 +++---
 .../storage/AbstractTaskStoreTest.java          | 26 --------------------
 3 files changed, 7 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/b2cc604a/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java b/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
index 2b3ee7b..36c462a 100644
--- a/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
+++ b/src/main/java/org/apache/aurora/scheduler/storage/db/DbModule.java
@@ -112,12 +112,9 @@ public final class DbModule extends PrivateModule {
         .putAll(jdbcUriArgs)
         // We always disable the MvStore, as it is in beta as of this writing.
         .put("MV_STORE", "false")
-        // In several scenarios, we initiate asynchronous work in the context of a transaction,
-        // which can cause the asynchronous work to read yet-to-be-committed data.  Since this
-        // is currently only used as an in-memory store, we allow reads of uncommitted data to match
-        // previous behavior of the map-based store, and allow this type of pattern to work without
-        // regression.
-        .put("LOCK_MODE", "0")
+        // READ COMMITTED transaction isolation.  More details here
+        // http://www.h2database.com/html/advanced.html?#transaction_isolation
+        .put("LOCK_MODE", "3")
         // Error-level reporting for H2.
         // See http://www.h2database.com/html/features.html#trace_options
         // TODO(wfarner): H2 can ship these to slf4j, but is too noisy at our default level (info).

http://git-wip-us.apache.org/repos/asf/aurora/blob/b2cc604a/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml
----------------------------------------------------------------------
diff --git a/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml b/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml
index e689cfe..db6c642 100644
--- a/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml
+++ b/src/main/resources/org/apache/aurora/scheduler/storage/db/TaskMapper.xml
@@ -58,7 +58,7 @@
       e.message AS message,
       e.scheduler_host AS scheduler
     FROM task_events AS e
-    WHERE e.task_row_id = #{id}
+    WHERE e.task_row_id = (SELECT id FROM tasks WHERE task_id = #{task_id})
     ORDER BY e.timestamp_ms ASC
   </select>
 
@@ -80,12 +80,12 @@
     <collection
         property="assignedTask.assignedPorts"
         select="selectPorts"
-        column="row_id"
+        column="task_id"
         foreignColumn="task_row_id"/>
     <collection
         property="taskEvents"
         select="selectTaskEvents"
-        column="row_id"
+        column="task_id"
         foreignColumn="task_row_id"/>
   </resultMap>
 
@@ -225,7 +225,7 @@
       name,
       port
     FROM task_ports
-    WHERE task_row_id = #{taskRowId}
+    WHERE task_row_id = (SELECT id FROM tasks WHERE task_id = #{task_id})
   </select>
 
   <delete id="truncate">

http://git-wip-us.apache.org/repos/asf/aurora/blob/b2cc604a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java b/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
index 3dba286..5a9b6c1 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
@@ -18,7 +18,6 @@ import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 
 import com.google.common.collect.FluentIterable;
@@ -540,31 +539,6 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
   }
 
   @Test
-  public void testLegacyPermissiveTransactionIsolation() throws Exception {
-    // Ensures that a thread launched within a transaction can read the uncommitted changes caused
-    // by the transaction.  This is not a pattern that we should embrace, but is necessary for
-    // DbStorage to match behavior with MemStorage.
-    // TODO(wfarner): Create something like a transaction-aware Executor so that we can still
-    // asynchronously react to a completed transaction, but in a way that allows for more strict
-    // transaction isolation.
-
-    ExecutorService executor = Executors.newFixedThreadPool(1,
-        new ThreadFactoryBuilder().setNameFormat("AsyncRead-%d").setDaemon(true).build());
-    addTearDown(() -> MoreExecutors.shutdownAndAwaitTermination(executor, 1, TimeUnit.SECONDS));
-
-    saveTasks(TASK_A);
-    storage.write((NoResult<Exception>) storeProvider -> {
-      IScheduledTask taskARunning = TaskTestUtil.addStateTransition(TASK_A, RUNNING, 1000L);
-      saveTasks(taskARunning);
-
-      Future<ScheduleStatus> asyncReadState = executor.submit(
-          () -> Iterables.getOnlyElement(fetchTasks(Query.taskScoped(Tasks.id(TASK_A))))
-              .getStatus());
-      assertEquals(RUNNING, asyncReadState.get());
-    });
-  }
-
-  @Test
   public void testNullVsEmptyRelations() throws Exception {
     // Test for regression of AURORA-1476.