Backed out 3 changesets (bug 1157029, bug 1155634, bug 1156063) for ASAN failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 06 May 2015 23:40:29 -0400
changeset 265887 5822851d291182d06feade235dd463748a190740
parent 265886 c53995c2fe1b13204beca609e2e24d502e86cc2b
child 265888 836f6b1688468729b7da9225a39cb058a37e41e9
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1157029, 1155634, 1156063
milestone39.0a2
backs out1cc599a8ff531f2ecb70b9ae2adc09a70aeb69a0
d6d584d072bb8875370ac4dc19c1ef1da4207b88
57fa7552c3c3691ea47fd8a65d99f12139d25069
Backed out 3 changesets (bug 1157029, bug 1155634, bug 1156063) for ASAN failures. Backed out changeset 1cc599a8ff53 (bug 1155634) Backed out changeset d6d584d072bb (bug 1157029) Backed out changeset 57fa7552c3c3 (bug 1156063) CLOSED TREE
dom/indexedDB/ActorsParent.cpp
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -5177,17 +5177,17 @@ public:
   }
 
   static bool
   IsShuttingDownOnMainThread()
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (sInstance) {
-      return sInstance->IsShuttingDown();
+      return sInstance->mShutdownRequested;
     }
 
     return QuotaManager::IsShuttingDown();
   }
 
   static bool
   IsShuttingDownOnNonMainThread()
   {
@@ -5258,21 +5258,23 @@ private:
                                UsageInfo* aUsageInfo,
                                bool aDatabaseFiles);
 };
 
 class QuotaClient::ShutdownTransactionThreadPoolRunnable final
   : public nsRunnable
 {
   nsRefPtr<QuotaClient> mQuotaClient;
+  bool mHasRequestedShutDown;
 
 public:
 
   explicit ShutdownTransactionThreadPoolRunnable(QuotaClient* aQuotaClient)
     : mQuotaClient(aQuotaClient)
+    , mHasRequestedShutDown(false)
   {
     MOZ_ASSERT(NS_IsMainThread());
     MOZ_ASSERT(aQuotaClient);
     MOZ_ASSERT(QuotaClient::GetInstance() == aQuotaClient);
     MOZ_ASSERT(aQuotaClient->mShutdownRequested);
   }
 
   NS_DECL_ISUPPORTS_INHERITED
@@ -5870,16 +5872,26 @@ Factory::~Factory()
 already_AddRefed<Factory>
 Factory::Create(const LoggingInfo& aLoggingInfo)
 {
   AssertIsOnBackgroundThread();
   MOZ_ASSERT(!QuotaClient::IsShuttingDownOnNonMainThread());
 
   // If this is the first instance then we need to do some initialization.
   if (!sFactoryInstanceCount) {
+    if (!gTransactionThreadPool) {
+      nsRefPtr<TransactionThreadPool> threadPool =
+        TransactionThreadPool::Create();
+      if (NS_WARN_IF(!threadPool)) {
+        return nullptr;
+      }
+
+      gTransactionThreadPool = threadPool;
+    }
+
     MOZ_ASSERT(!gLiveDatabaseHashtable);
     gLiveDatabaseHashtable = new DatabaseActorHashtable();
 
     MOZ_ASSERT(!gStartTransactionRunnable);
     gStartTransactionRunnable = new nsRunnable();
 
     MOZ_ASSERT(!gLoggingInfoHashtable);
     gLoggingInfoHashtable = new DatabaseLoggingInfoHashtable();
@@ -6522,26 +6534,16 @@ Database::RecvPBackgroundIDBTransactionC
   MOZ_ASSERT(!mClosed);
 
   if (IsInvalidated()) {
     // This is an expected race. We don't want the child to die here, just don't
     // actually do any work.
     return true;
   }
 
-  if (!gTransactionThreadPool) {
-    nsRefPtr<TransactionThreadPool> threadPool =
-      TransactionThreadPool::Create();
-    if (NS_WARN_IF(!threadPool)) {
-      return nullptr;
-    }
-
-    gTransactionThreadPool = threadPool;
-  }
-
   auto* transaction = static_cast<NormalTransaction*>(aActor);
 
   // Add a placeholder for this transaction immediately.
   gTransactionThreadPool->Start(transaction->TransactionId(),
                                 mMetadata->mDatabaseId,
                                 aObjectStoreNames,
                                 aMode,
                                 GetLoggingInfo()->Id(),
@@ -9854,32 +9856,38 @@ WaitForTransactionsRunnable::Run()
 NS_IMPL_ISUPPORTS_INHERITED0(QuotaClient::ShutdownTransactionThreadPoolRunnable,
                              nsRunnable)
 
 NS_IMETHODIMP
 QuotaClient::
 ShutdownTransactionThreadPoolRunnable::Run()
 {
   if (NS_IsMainThread()) {
+    MOZ_ASSERT(mHasRequestedShutDown);
     MOZ_ASSERT(QuotaClient::GetInstance() == mQuotaClient);
     MOZ_ASSERT(mQuotaClient->mShutdownRunnable == this);
 
     mQuotaClient->mShutdownRunnable = nullptr;
     mQuotaClient = nullptr;
 
     return NS_OK;
   }
 
   AssertIsOnBackgroundThread();
 
-  nsRefPtr<TransactionThreadPool> threadPool = gTransactionThreadPool.get();
-  if (threadPool) {
-    threadPool->Shutdown();
-
-    gTransactionThreadPool = nullptr;
+  if (!mHasRequestedShutDown) {
+    mHasRequestedShutDown = true;
+
+    nsRefPtr<TransactionThreadPool> threadPool = gTransactionThreadPool.get();
+    if (threadPool) {
+      threadPool->Shutdown();
+
+      gTransactionThreadPool = nullptr;
+    }
+
   }
 
   MOZ_ALWAYS_TRUE(NS_SUCCEEDED(NS_DispatchToMainThread(this)));
 
   return NS_OK;
 }
 
 /*******************************************************************************
@@ -11711,16 +11719,17 @@ OpenDatabaseOp::BeginVersionChange()
   AssertIsOnOwningThread();
   MOZ_ASSERT(mState == State_BeginVersionChange);
   MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
   MOZ_ASSERT(mMetadata->mCommonMetadata.version() <= mRequestedVersion);
   MOZ_ASSERT(!mDatabase);
   MOZ_ASSERT(!mVersionChangeTransaction);
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonMainThread()) ||
+      !OperationMayProceed() ||
       IsActorDestroyed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   EnsureDatabaseActor();
 
   if (mDatabase->IsInvalidated()) {
@@ -11828,33 +11837,21 @@ OpenDatabaseOp::DispatchToWorkThread()
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mState == State_WaitingForTransactionsToComplete);
   MOZ_ASSERT(mVersionChangeTransaction);
   MOZ_ASSERT(mVersionChangeTransaction->GetMode() ==
                IDBTransaction::VERSION_CHANGE);
   MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
 
-  if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonMainThread()) ||
-      IsActorDestroyed()) {
+  if (IsActorDestroyed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
-  if (!gTransactionThreadPool) {
-    nsRefPtr<TransactionThreadPool> threadPool =
-      TransactionThreadPool::Create();
-    if (!threadPool) {
-      IDB_REPORT_INTERNAL_ERR();
-      return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
-    }
-
-    gTransactionThreadPool = threadPool;
-  }
-
   mState = State_DatabaseWorkVersionChange;
 
   // Intentionally empty.
   nsTArray<nsString> objectStoreNames;
 
   const int64_t loggingSerialNumber =
     mVersionChangeTransaction->LoggingSerialNumber();
   const nsID& backgroundChildLoggingId =
@@ -11887,16 +11884,17 @@ OpenDatabaseOp::SendUpgradeNeeded()
   AssertIsOnOwningThread();
   MOZ_ASSERT(mState == State_DatabaseWorkVersionChange);
   MOZ_ASSERT(mVersionChangeTransaction);
   MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
   MOZ_ASSERT(NS_SUCCEEDED(mResultCode));
   MOZ_ASSERT_IF(!IsActorDestroyed(), mDatabase);
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonMainThread()) ||
+      !OperationMayProceed() ||
       IsActorDestroyed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   nsRefPtr<VersionChangeTransaction> transaction;
   mVersionChangeTransaction.swap(transaction);
 
@@ -11947,21 +11945,17 @@ OpenDatabaseOp::SendResults()
 
   if (mVersionChangeTransaction) {
     MOZ_ASSERT(NS_FAILED(mResultCode));
 
     mVersionChangeTransaction->Abort(mResultCode, /* aForce */ true);
     mVersionChangeTransaction = nullptr;
   }
 
-  if (IsActorDestroyed()) {
-    if (NS_SUCCEEDED(mResultCode)) {
-      mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
-    }
-  } else {
+  if (!IsActorDestroyed()) {
     FactoryRequestResponse response;
 
     if (NS_SUCCEEDED(mResultCode)) {
       // If we just successfully completed a versionchange operation then we
       // need to update the version in our metadata.
       mMetadata->mCommonMetadata.version() = mRequestedVersion;
 
       nsresult rv = EnsureDatabaseActorIsAlive();
@@ -11986,30 +11980,25 @@ OpenDatabaseOp::SendResults()
 #endif
       response = ClampResultCode(mResultCode);
     }
 
     unused <<
       PBackgroundIDBFactoryRequestParent::Send__delete__(this, response);
   }
 
-  if (mDatabase) {
-    MOZ_ASSERT(!mOfflineStorage);
-
-    if (NS_FAILED(mResultCode)) {
-      mDatabase->Invalidate();
-    }
-
-    // Make sure to release the database on this thread.
-    mDatabase = nullptr;
-  } else if (mOfflineStorage) {
+  if (NS_FAILED(mResultCode) && mOfflineStorage) {
     mOfflineStorage->CloseOnOwningThread();
     DatabaseOfflineStorage::UnregisterOnOwningThread(mOfflineStorage.forget());
   }
 
+  // Make sure to release the database on this thread.
+  nsRefPtr<Database> database;
+  mDatabase.swap(database);
+
   FinishSendResults();
 }
 
 void
 OpenDatabaseOp::EnsureDatabaseActor()
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mState == State_BeginVersionChange ||
@@ -12593,16 +12582,17 @@ DeleteDatabaseOp::DoDatabaseWork()
 nsresult
 DeleteDatabaseOp::BeginVersionChange()
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mState == State_BeginVersionChange);
   MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonMainThread()) ||
+      !OperationMayProceed() ||
       IsActorDestroyed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   DatabaseActorInfo* info;
   if (gLiveDatabaseHashtable->Get(mDatabaseId, &info)) {
     MOZ_ASSERT(!info->mWaitingFactoryOp);
@@ -12632,16 +12622,17 @@ DeleteDatabaseOp::BeginVersionChange()
 nsresult
 DeleteDatabaseOp::DispatchToWorkThread()
 {
   AssertIsOnOwningThread();
   MOZ_ASSERT(mState == State_WaitingForTransactionsToComplete);
   MOZ_ASSERT(mMaybeBlockedDatabases.IsEmpty());
 
   if (NS_WARN_IF(QuotaClient::IsShuttingDownOnNonMainThread()) ||
+      !OperationMayProceed() ||
       IsActorDestroyed()) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
   }
 
   mState = State_DatabaseWorkVersionChange;
 
   nsRefPtr<VersionChangeOp> versionChangeOp = new VersionChangeOp(this);