Changeset 54162 in webkit


Ignore:
Timestamp:
Feb 1, 2010 3:32:44 PM (14 years ago)
Author:
dumi@chromium.org
Message:

Making sure that all in-progress transactions are rolled back on
the database thread before they're destroyed. Otherwise,
SQLiteTransaction's destructor will try to do a rollback and that
would cause an assertion failure, if the object is not destroyed
on the DB thread.

Reviewed by Eric Seidel.

https://bugs.webkit.org/show_bug.cgi?id=34152

  • platform/sql/SQLiteTransaction.cpp:

(WebCore::SQLiteTransaction::stop):

  • storage/SQLTransaction.cpp:

(WebCore::SQLTransaction::notifyDatabaseThreadIsShuttingDown):

  • storage/SQLTransaction.h:
  • storage/SQLTransactionCoordinator.cpp:

(WebCore::SQLTransactionCoordinator::shutdown):

Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r54156 r54162  
     12010-02-01  Dumitru Daniliuc  <dumi@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Making sure that all in-progress transactions are rolled back on
     6        the database thread before they're destroyed. Otherwise,
     7        SQLiteTransaction's destructor will try to do a rollback and that
     8        would cause an assertion failure, if the object is not destroyed
     9        on the DB thread.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=34152
     12
     13        * platform/sql/SQLiteTransaction.cpp:
     14        (WebCore::SQLiteTransaction::stop):
     15        * storage/SQLTransaction.cpp:
     16        (WebCore::SQLTransaction::notifyDatabaseThreadIsShuttingDown):
     17        * storage/SQLTransaction.h:
     18        * storage/SQLTransactionCoordinator.cpp:
     19        (WebCore::SQLTransactionCoordinator::shutdown):
     20
    1212010-02-01  Sam Weinig  <sam@webkit.org>
    222
  • trunk/WebCore/platform/sql/SQLiteTransaction.cpp

    r48897 r54162  
    6565void SQLiteTransaction::commit()
    6666{
     67    // FIXME: this code is buggy; it assumes that COMMIT always succeeds which is not the case:
     68    // the transaction could've been silently rolled back before getting to the COMMIT statement
     69    // (https://bugs.webkit.org/show_bug.cgi?id=34280). However, the rest of the code does not
     70    // know how to deal with a premature rollback and a failed COMMIT at this moment, so until
     71    // we figure out what to do with bug 34280, it's better to leave this code as it is.
    6772    if (m_inProgress) {
    6873        ASSERT(m_db.m_transactionInProgress);
     
    8590void SQLiteTransaction::stop()
    8691{
    87     m_inProgress = false;
    88     m_db.m_transactionInProgress = false;
     92    if (m_inProgress) {
     93        m_inProgress = false;
     94        m_db.m_transactionInProgress = false;
     95    }
    8996}
    9097
  • trunk/WebCore/storage/SQLTransaction.cpp

    r53595 r54162  
    3636#include "DatabaseAuthorizer.h"
    3737#include "DatabaseDetails.h"
     38#include "DatabaseThread.h"
    3839#include "ExceptionCode.h"
    3940#include "Logging.h"
     
    8485SQLTransaction::~SQLTransaction()
    8586{
     87    ASSERT(!m_sqliteTransaction);
    8688}
    8789
     
    204206}
    205207
     208void SQLTransaction::notifyDatabaseThreadIsShuttingDown()
     209{
     210    ASSERT(currentThread() == database()->scriptExecutionContext()->databaseThread()->getThreadID());
     211
     212    // If the transaction is in progress, we should roll it back here, since this is our last
     213    // oportunity to do something related to this transaction on the DB thread.
     214    // Clearing m_sqliteTransaction invokes SQLiteTransaction's destructor which does just that.
     215    m_sqliteTransaction.clear();
     216}
     217
    206218void SQLTransaction::acquireLock()
    207219{
     
    492504    LOG(StorageAPI, "Transaction %p is complete\n", this);
    493505    ASSERT(!m_database->m_sqliteDatabase.transactionInProgress());
     506    m_sqliteTransaction.clear();
    494507    m_nextStep = 0;
    495508
  • trunk/WebCore/storage/SQLTransaction.h

    r48653 r54162  
    8181    Database* database() { return m_database.get(); }
    8282    bool isReadOnly() { return m_readOnly; }
     83    void notifyDatabaseThreadIsShuttingDown();
    8384
    8485private:
  • trunk/WebCore/storage/SQLTransactionCoordinator.cpp

    r52060 r54162  
    110110void SQLTransactionCoordinator::shutdown()
    111111{
     112    // Notify all transactions in progress that the database thread is shutting down
     113    for (CoordinationInfoMap::iterator coordinationInfoIterator = m_coordinationInfoMap.begin();
     114         coordinationInfoIterator != m_coordinationInfoMap.end(); ++coordinationInfoIterator) {
     115        CoordinationInfo& info = coordinationInfoIterator->second;
     116        if (info.activeWriteTransaction)
     117            info.activeWriteTransaction->notifyDatabaseThreadIsShuttingDown();
     118        for (HashSet<RefPtr<SQLTransaction> >::iterator activeReadTransactionsIterator =
     119                     info.activeReadTransactions.begin();
     120             activeReadTransactionsIterator != info.activeReadTransactions.end();
     121             ++activeReadTransactionsIterator) {
     122            (*activeReadTransactionsIterator)->notifyDatabaseThreadIsShuttingDown();
     123        }
     124    }
     125
    112126    // Clean up all pending transactions for all databases
    113127    m_coordinationInfoMap.clear();
Note: See TracChangeset for help on using the changeset viewer.