You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aurora.apache.org by jc...@apache.org on 2016/04/21 21:24:06 UTC

aurora git commit: Fix bug when fetching a task with multiple assigned ports.

Repository: aurora
Updated Branches:
  refs/heads/master 15eaa5d1e -> 12e92642f


Fix bug when fetching a task with multiple assigned ports.

Because we did not include the ids for task ports and task events in the query when mybatis tried
to map the results, there was no way to identify the task events returned in each additional row
for ports as distinct. This resulted in each subsequent task fetch tacking on extra task events.

Bugs closed: AURORA-1672

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


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

Branch: refs/heads/master
Commit: 12e92642f965f6db2447f8989d9d10cb90ea0732
Parents: 15eaa5d
Author: Joshua Cohen <jc...@apache.org>
Authored: Thu Apr 21 14:23:45 2016 -0500
Committer: Joshua Cohen <jc...@apache.org>
Committed: Thu Apr 21 14:23:45 2016 -0500

----------------------------------------------------------------------
 .../apache/aurora/scheduler/storage/db/TaskMapper.xml  |  7 +++++++
 .../scheduler/storage/AbstractTaskStoreTest.java       | 13 +++++++++++++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aurora/blob/12e92642/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 fb78a39..b75e2b0 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
@@ -81,6 +81,11 @@
   </resultMap>
 
   <sql id="unscopedSelect">
+    <!--
+    N.B. For any one-to-many relationship, results from the joined table *must* include the id
+    otherwise mybatis will not be able to disambiguate identical rows leading to an explosion
+    of related rows on each save.
+    -->
     SELECT
       t.id AS row_id,
       t.task_config_row_id AS task_config_row_id,
@@ -94,8 +99,10 @@
       j.name AS c_j_name,
       h.slave_id AS slave_id,
       h.host AS slave_host,
+      tp.id as tp_id,
       tp.name as tp_name,
       tp.port as tp_port,
+      te.id as te_id,
       te.timestamp_ms as te_timestamp,
       te.status as te_status,
       te.message as te_message,

http://git-wip-us.apache.org/repos/asf/aurora/blob/12e92642/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 310c4d8..af56115 100644
--- a/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
+++ b/src/test/java/org/apache/aurora/scheduler/storage/AbstractTaskStoreTest.java
@@ -208,6 +208,19 @@ public abstract class AbstractTaskStoreTest extends TearDownTestCase {
   }
 
   @Test
+  public void testSaveWithMultiplePorts() {
+    ScheduledTask builder = TASK_A.newBuilder();
+    builder.getAssignedTask().setAssignedPorts(ImmutableMap.of("http", 1000, "tcp", 2000));
+    IScheduledTask task = IScheduledTask.build(builder);
+    saveTasks(task);
+
+    Optional<IScheduledTask> maybeTask = fetchTask(task.getAssignedTask().getTaskId());
+    saveTasks(maybeTask.get());
+
+    assertStoreContents(task);
+  }
+
+  @Test
   public void testQuery() {
     assertStoreContents();
     saveTasks(TASK_A, TASK_B, TASK_C, TASK_D);