Bug 1309527 - Fix the race condition to prevent the access of metadata in both PBackground thread and the Connection thread. r=janv
☠☠ backed out by 1633ac89c6ac ☠ ☠
authorBevis Tseng <btseng@mozilla.com>
Wed, 26 Oct 2016 19:14:12 +0800
changeset 347369 2bbfcf5356f78dd54db4c1a445aab8b34d5b0223
parent 347368 128a3d8cea98a31e656cf51800830b85b1abbf7e
child 347370 e71702af187bf95d74a345b139d5835d91bea611
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv
bugs1309527
milestone52.0a1
Bug 1309527 - Fix the race condition to prevent the access of metadata in both PBackground thread and the Connection thread. r=janv
dom/indexedDB/ActorsParent.cpp
testing/web-platform/meta/IndexedDB/idbindex-rename.html.ini
testing/web-platform/meta/IndexedDB/idbobjectstore-rename-store.html.ini
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -7910,26 +7910,28 @@ private:
   DoDatabaseWork(DatabaseConnection* aConnection) override;
 };
 
 class RenameObjectStoreOp final
   : public VersionChangeTransactionOp
 {
   friend class VersionChangeTransaction;
 
-  const RefPtr<FullObjectStoreMetadata> mMetadata;
+  const int64_t mId;
+  const nsString mNewName;
 
 private:
   // Only created by VersionChangeTransaction.
   RenameObjectStoreOp(VersionChangeTransaction* aTransaction,
                       FullObjectStoreMetadata* const aMetadata)
     : VersionChangeTransactionOp(aTransaction)
-    , mMetadata(aMetadata)
-  {
-    MOZ_ASSERT(aMetadata->mCommonMetadata.id());
+    , mId(aMetadata->mCommonMetadata.id())
+    , mNewName(aMetadata->mCommonMetadata.name())
+  {
+    MOZ_ASSERT(mId);
   }
 
   ~RenameObjectStoreOp()
   { }
 
   virtual nsresult
   DoDatabaseWork(DatabaseConnection* aConnection) override;
 };
@@ -8104,29 +8106,31 @@ private:
   DoDatabaseWork(DatabaseConnection* aConnection) override;
 };
 
 class RenameIndexOp final
   : public VersionChangeTransactionOp
 {
   friend class VersionChangeTransaction;
 
-  const RefPtr<FullIndexMetadata> mMetadata;
   const int64_t mObjectStoreId;
+  const int64_t mIndexId;
+  const nsString mNewName;
 
 private:
   // Only created by VersionChangeTransaction.
   RenameIndexOp(VersionChangeTransaction* aTransaction,
                 FullIndexMetadata* const aMetadata,
                 int64_t aObjectStoreId)
     : VersionChangeTransactionOp(aTransaction)
-    , mMetadata(aMetadata)
     , mObjectStoreId(aObjectStoreId)
-  {
-    MOZ_ASSERT(aMetadata->mCommonMetadata.id());
+    , mIndexId(aMetadata->mCommonMetadata.id())
+    , mNewName(aMetadata->mCommonMetadata.name())
+  {
+    MOZ_ASSERT(mIndexId);
   }
 
   ~RenameIndexOp()
   { }
 
   virtual nsresult
   DoDatabaseWork(DatabaseConnection* aConnection) override;
 };
@@ -24391,22 +24395,20 @@ RenameObjectStoreOp::DoDatabaseWork(Data
       aConnection->GetCachedStatement(NS_LITERAL_CSTRING(
         "SELECT name "
           "FROM object_store "
           "WHERE name = :name "
           "AND id != :id;"),
         &stmt));
 
     MOZ_ALWAYS_SUCCEEDS(
-      stmt->BindStringByName(NS_LITERAL_CSTRING("name"),
-                             mMetadata->mCommonMetadata.name()));
+      stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mNewName));
 
     MOZ_ALWAYS_SUCCEEDS(
-      stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"),
-                            mMetadata->mCommonMetadata.id()));
+      stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mId));
 
     bool hasResult;
     MOZ_ALWAYS_SUCCEEDS(stmt->ExecuteStep(&hasResult));
     MOZ_ASSERT(!hasResult);
   }
 #endif
 
   DatabaseConnection::AutoSavepoint autoSave;
@@ -24420,25 +24422,23 @@ RenameObjectStoreOp::DoDatabaseWork(Data
     "UPDATE object_store "
       "SET name = :name "
       "WHERE id = :id;"),
     &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"),
-                              mMetadata->mCommonMetadata.name());
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"),
-                             mMetadata->mCommonMetadata.id());
+  rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mNewName);
+
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mId);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -25501,22 +25501,20 @@ RenameIndexOp::DoDatabaseWork(DatabaseCo
            "AND id != :id;"),
         &stmt));
 
     MOZ_ALWAYS_SUCCEEDS(
       stmt->BindInt64ByName(NS_LITERAL_CSTRING("object_store_id"),
                             mObjectStoreId));
 
     MOZ_ALWAYS_SUCCEEDS(
-      stmt->BindStringByName(NS_LITERAL_CSTRING("name"),
-                             mMetadata->mCommonMetadata.name()));
+      stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mNewName));
 
     MOZ_ALWAYS_SUCCEEDS(
-      stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"),
-                            mMetadata->mCommonMetadata.id()));
+      stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mIndexId));
 
     bool hasResult;
     MOZ_ALWAYS_SUCCEEDS(stmt->ExecuteStep(&hasResult));
     MOZ_ASSERT(!hasResult);
   }
 #else
   Unused << mObjectStoreId;
 #endif
@@ -25532,25 +25530,23 @@ RenameIndexOp::DoDatabaseWork(DatabaseCo
     "UPDATE object_store_index "
       "SET name = :name "
       "WHERE id = :id;"),
     &stmt);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
-  rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"),
-                              mMetadata->mCommonMetadata.name());
-
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
-  }
-
-  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"),
-                             mMetadata->mCommonMetadata.id());
+  rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mNewName);
+
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return rv;
+  }
+
+  rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mIndexId);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   rv = stmt->Execute();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
deleted file mode 100644
--- a/testing/web-platform/meta/IndexedDB/idbindex-rename.html.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-[idbindex-rename.html]
-  type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1309527
-  expected:
-    if debug and not e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): CRASH
-    if debug and not e10s and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): CRASH
-    if debug and not e10s and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): CRASH
-    if debug and e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): CRASH
-    if debug and e10s and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): CRASH
-    if debug and not e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): CRASH
-    if debug and e10s and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): CRASH
deleted file mode 100644
--- a/testing/web-platform/meta/IndexedDB/idbobjectstore-rename-store.html.ini
+++ /dev/null
@@ -1,22 +0,0 @@
-[idbobjectstore-rename-store.html]
-  type: testharness
-  disabled: https://bugzilla.mozilla.org/show_bug.cgi?id=1309527
-  expected:
-    if debug and not e10s and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): CRASH
-    if debug and not e10s and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): CRASH
-    if debug and e10s and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): CRASH
-    if debug and e10s and (os == "mac") and (version == "OS X 10.10.5") and (processor == "x86_64") and (bits == 64): CRASH
-    if not debug and e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
-    if debug and e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): CRASH
-    if debug and e10s and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): CRASH
-    if not debug and not e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
-    if debug and not e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): CRASH
-  [IndexedDB object store can be renamed to "\\u0000"]
-    expected:
-      if not debug and not e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
-
-  [IndexedDB object store can be renamed to "\\uDC00\\uD800"]
-    expected:
-      if not debug and e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
-      if not debug and not e10s and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): NOTRUN
-