Bug 1309527 - Fix the race condition to prevent the access of metadata in both PBackground thread and the Connection thread. r=janv
authorBevis Tseng <btseng@mozilla.com>
Wed, 26 Oct 2016 19:14:12 +0800
changeset 351319 f98d9da756c77935e344330f75651145c95c4465
parent 351318 6c8fa338a908091cabd38345bc765c0eb3f3516f
child 351320 33b4d8c005c4e68c11a10a366719593c6b40819e
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [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
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/IndexedDB/idbindex-rename.html
testing/web-platform/tests/IndexedDB/idbobjectstore-rename-store.html
--- 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
-
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -38458,16 +38458,30 @@
                 "=="
               ]
             ],
             "url": "/html/semantics/grouping-content/the-ol-element/reversed-1e.html"
           }
         ]
       },
       "testharness": {
+        "IndexedDB/idbindex-rename.html": [
+          {
+            "path": "IndexedDB/idbindex-rename.html",
+            "timeout": "long",
+            "url": "/IndexedDB/idbindex-rename.html"
+          }
+        ],
+        "IndexedDB/idbobjectstore-rename-store.html": [
+          {
+            "path": "IndexedDB/idbobjectstore-rename-store.html",
+            "timeout": "long",
+            "url": "/IndexedDB/idbobjectstore-rename-store.html"
+          }
+        ],
         "WebCryptoAPI/generateKey/failures_AES-CBC.worker.js": [
           {
             "path": "WebCryptoAPI/generateKey/failures_AES-CBC.worker.js",
             "timeout": "long",
             "url": "/WebCryptoAPI/generateKey/failures_AES-CBC.worker"
           }
         ],
         "WebCryptoAPI/generateKey/failures_AES-CTR.worker.js": [
--- a/testing/web-platform/tests/IndexedDB/idbindex-rename.html
+++ b/testing/web-platform/tests/IndexedDB/idbindex-rename.html
@@ -1,9 +1,10 @@
 <!DOCTYPE html>
+<meta name="timeout" content="long">
 <title>IndexedDB: index renaming support</title>
 <link rel="help"
       href="https://w3c.github.io/IndexedDB/#dom-idbindex-name">
 <link rel="author" href="pwnall@chromium.org" title="Victor Costan">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="support-promises.js"></script>
 <script>
--- a/testing/web-platform/tests/IndexedDB/idbobjectstore-rename-store.html
+++ b/testing/web-platform/tests/IndexedDB/idbobjectstore-rename-store.html
@@ -1,9 +1,10 @@
 <!DOCTYPE html>
+<meta name="timeout" content="long">
 <title>IndexedDB: object store renaming support</title>
 <link rel="help"
       href="https://w3c.github.io/IndexedDB/#dom-idbobjectstore-name">
 <link rel="author" href="pwnall@chromium.org" title="Victor Costan">
 <script src="/resources/testharness.js"></script>
 <script src="/resources/testharnessreport.js"></script>
 <script src="support-promises.js"></script>
 <script>