Below is the list of changes that have just been committed into a local
6.0 repository of cpowers. When cpowers does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-03-03 12:40:17-06:00, cpowers@stripped +24 -0
Bug#34567, "Falcon deadlock between ALTERs of temporary tables
System QA stress tests caused deadlocks during DDL operations.
Moved DDL locks out of low-level classes.
Replaced Database::syncSysConnection with Database::syncSysDDL.
Exclusively lock all DDL via Statement::executeDDL.
storage/falcon/Applications.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +4 -4
Replaced Database::syncSysConnection locks with syncSysDDL.
storage/falcon/Database.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +128 -76
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/Database.h@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +2 -3
Replaced Database::syncSysConnection with syncSysDDL.
storage/falcon/Field.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +0 -7
Removed syncSysConnection locks.
storage/falcon/FilterSet.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +0 -4
Removed syncSysConnection locks.
storage/falcon/FilterSetManager.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +0 -6
Removed syncSysConnection locks.
storage/falcon/ForeignKey.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +0 -11
Removed syncSysConnection locks.
storage/falcon/Format.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +0 -2
Removed syncSysConnection locks.
storage/falcon/ImageManager.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +6 -0
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/Images.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +0 -2
Removed syncSysConnection locks.
storage/falcon/Index.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +0 -13
Removed syncSysConnection locks.
storage/falcon/LicenseManager.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +2 -2
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/Repository.cpp@stripped, 2008-03-03 12:40:14-06:00, cpowers@stripped +4 -7
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/RepositoryVolume.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +3 -4
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/Role.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +0 -3
Removed syncSysConnection locks.
storage/falcon/RoleModel.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +4 -56
Removed syncSysConnection locks.
storage/falcon/Scheduler.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +13 -13
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/Schema.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +1 -5
Removed syncSysConnection locks.
storage/falcon/SequenceManager.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +6 -14
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/Statement.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +3 -15
Removed several syncSysConnection locks.
Replaced remaining syncSysConnection references with syncSysDDL.
storage/falcon/StorageDatabase.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +4 -12
Replaced Database::syncSysConnection with syncSysDDL.
Reordered lock sequence in ::renameTable and ::truncateTable.
storage/falcon/Table.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +11 -38
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
storage/falcon/TableSpaceManager.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +26 -21
Replaced Database::syncSysConnection with syncSysDDL.
storage/falcon/Trigger.cpp@stripped, 2008-03-03 12:40:15-06:00, cpowers@stripped +0 -11
Replaced Database::syncSysConnection with syncSysDDL.
Moved system DDL locks higher in the class hierarchy.
diff -Nrup a/storage/falcon/Applications.cpp b/storage/falcon/Applications.cpp
--- a/storage/falcon/Applications.cpp 2008-01-03 16:12:24 -06:00
+++ b/storage/falcon/Applications.cpp 2008-03-03 12:40:14 -06:00
@@ -105,7 +105,7 @@ Application* Applications::getApplicatio
database->execute (populate);
}
- Sync sync (&database->syncSysConnection, "Applications::getApplication");
+ Sync syncDDL(&database->syncSysDDL, "Applications::getApplication");
PreparedStatement *statement = database->prepareStatement (
"select extends,classname"
@@ -115,7 +115,7 @@ Application* Applications::getApplicatio
for (n = 0; !application && n < 2; ++n)
{
- sync.lock (Shared);
+ syncDDL.lock (Shared);
ResultSet *resultSet = statement->executeQuery();
if (resultSet->next())
@@ -128,7 +128,7 @@ Application* Applications::getApplicatio
JString className = resultSet->getString (2);
resultSet->close();
- sync.unlock();
+ syncDDL.unlock();
bool mandatory = className == "netfrastructure/model/Application";
Manifest *manifest = database->java->findManifest (className);
@@ -158,7 +158,7 @@ Application* Applications::getApplicatio
else
{
resultSet->close();
- sync.unlock();
+ syncDDL.unlock();
}
if (!application && !strcmp (applicationName, BASE))
{
diff -Nrup a/storage/falcon/Database.cpp b/storage/falcon/Database.cpp
--- a/storage/falcon/Database.cpp 2008-02-20 15:16:03 -06:00
+++ b/storage/falcon/Database.cpp 2008-03-03 12:40:14 -06:00
@@ -472,11 +472,10 @@ Database::Database(const char *dbName, C
syncTables.setName("Database::syncTables");
syncStatements.setName("Database::syncStatements");
syncAddStatement.setName("Database::syncAddStatement");
- syncSysConnection.setName("Database::syncSysConnection");
syncResultSets.setName("Database::syncResultSets");
syncConnectionStatements.setName("Database::syncConnectionStatements");
syncScavenge.setName("Database::syncScavenge");
- syncDDL.setName("Database::syncDDL");
+ syncSysDDL.setName("Database::syncSysDDL");
}
@@ -636,6 +635,10 @@ void Database::createDatabase(const char
odsVersion = dbb->odsVersion;
dbb->createInversion(0);
Table *table;
+
+ Sync syncDDL(&syncSysDDL, "Database::createDatabase");
+ syncDDL.lock(Exclusive);
+
Transaction *sysTrans = getSystemTransaction();
for (table = tableList; table; table = table->next)
@@ -981,8 +984,10 @@ Table* Database::findTable (const char *
schema = symbolManager->getSymbol (schema);
name = symbolManager->getSymbol (name);
- Sync sync (&syncTables, "Database::findTable");
- sync.lock (Shared);
+
+ Sync syncTbl (&syncTables, "Database::findTable");
+ syncTbl.lock (Shared);
+
int slot = HASH (name, TABLE_HASH_SIZE);
Table *table;
@@ -990,15 +995,15 @@ Table* Database::findTable (const char *
if (table->name == name && table->schemaName == schema)
return table;
- sync.unlock();
+ syncTbl.unlock();
for (UnTable *untable = unTables [slot]; untable;
untable = untable->collision)
if (untable->name == name && untable->schemaName == schema)
return NULL;
- Sync syncSystemTransaction(&syncSysConnection, "Database::findTable");
- syncSystemTransaction.lock(Shared);
+ Sync syncDDL(&syncSysDDL, "Database::findTable");
+ syncDDL.lock(Shared);
PStatement statement = prepareStatement (
(fieldExtensions) ?
@@ -1127,15 +1132,19 @@ PreparedStatement* Database::prepareStat
CompiledStatement* Database::getCompiledStatement(Connection *connection, const char * sqlString)
{
- Sync sync (&syncStatements, "Database::getCompiledStatement(1)");
- sync.lock (Shared);
+ Sync syncDDL(&syncSysDDL, "Database::getCompiledStatement(1)");
+ syncDDL.lock(Shared);
+
+ Sync syncStmt(&syncStatements, "Database::getCompiledStatement(1)");
+ syncStmt.lock(Shared);
+
//printf("%s\n", (const char*) sqlString);
for (CompiledStatement *statement = compiledStatements; statement; statement = statement->next)
if (statement->sqlString == sqlString && statement->validate (connection))
{
statement->addRef();
- sync.unlock();
+ syncStmt.unlock();
try
{
statement->checkAccess (connection);
@@ -1148,16 +1157,19 @@ CompiledStatement* Database::getCompiled
return statement;
}
- sync.unlock();
+ syncStmt.unlock();
return compileStatement (connection, sqlString);
}
-
CompiledStatement* Database::getCompiledStatement(Connection *connection, const WCString *sqlString)
{
- Sync sync (&syncStatements, "Database::getCompiledStatement(WC)");
- sync.lock (Shared);
+ Sync syncDDL(&syncSysDDL, "Database::getCompiledStatement(WC)");
+ syncDDL.lock(Shared);
+
+ Sync syncStmt(&syncStatements, "Database::getCompiledStatement(WC)");
+ syncStmt.lock(Shared);
+
//JString str(sqlString);
//printf("%s\n", (const char*) str);
@@ -1165,7 +1177,7 @@ CompiledStatement* Database::getCompiled
if (statement->sqlString == sqlString && statement->validate (connection))
{
statement->addRef();
- sync.unlock();
+ syncStmt.unlock();
try
{
statement->checkAccess (connection);
@@ -1178,7 +1190,7 @@ CompiledStatement* Database::getCompiled
return statement;
}
- sync.unlock();
+ syncStmt.unlock();
JString sql (sqlString);
return compileStatement (connection, sql);
@@ -1186,6 +1198,9 @@ CompiledStatement* Database::getCompiled
CompiledStatement* Database::compileStatement(Connection *connection, JString sqlString)
{
+ Sync syncDDL(&syncSysDDL, "Database::getCompiledStatement(WC)");
+ syncDDL.lock(Shared);
+
CompiledStatement *statement = new CompiledStatement (connection);
try
@@ -1202,10 +1217,10 @@ CompiledStatement* Database::compileStat
if (statement->useable &&
(statement->numberParameters > 0 || !statement->filters.isEmpty()))
{
- Sync sync (&syncStatements, "Database::compileStatement(1)");
- sync.lock (Shared);
- Sync sync2 (&syncAddStatement, "Database::compileStatement(2)");
- sync2.lock (Exclusive);
+ Sync syncStmt (&syncStatements, "Database::compileStatement(1)");
+ syncStmt.lock (Shared);
+ Sync syncAddStmt (&syncAddStatement, "Database::compileStatement(2)");
+ syncAddStmt.lock (Exclusive);
statement->addRef();
statement->next = compiledStatements;
compiledStatements = statement;
@@ -1233,14 +1248,14 @@ bool Database::flush(int64 arg)
void Database::commitSystemTransaction()
{
- Sync sync (&syncSysConnection, "Database::commitSystemTransaction");
+ Sync sync (&syncSysDDL, "Database::commitSystemTransaction");
sync.lock (Exclusive);
systemConnection->commit();
}
void Database::rollbackSystemTransaction(void)
{
- Sync sync (&syncSysConnection, "Database::commitSystemTransaction");
+ Sync sync (&syncSysDDL, "Database::commitSystemTransaction");
sync.lock (Exclusive);
systemConnection->rollback();
}
@@ -1286,6 +1301,9 @@ Table* Database::getTable(int tableId)
{
Table *table;
+ Sync syncDDL(&syncSysDDL, "Database::getTable");
+ syncDDL.lock(Shared);
+
for (table = tablesModId [tableId % TABLE_HASH_SIZE]; table;
table = table->idCollision)
if (table->tableId == tableId)
@@ -1303,8 +1321,11 @@ Table* Database::getTable(int tableId)
Table* Database::loadTable(ResultSet * resultSet)
{
- Sync sync(&syncTables, "Database::loadTable");
+ Sync syncDDL(&syncSysDDL, "Database::loadTable");
+ syncDDL.lock(Shared);
+ Sync syncObj(&syncTables, "Database::loadTable");
+
if (!resultSet->next())
return NULL;
@@ -1348,7 +1369,8 @@ Table* Database::loadTable(ResultSet * r
}
table->loadStuff();
- sync.lock(Exclusive);
+
+ syncObj.lock(Exclusive);
addTable(table);
return table;
@@ -1365,8 +1387,11 @@ void Database::flushInversion(Transactio
dbb->inversion->flush (TRANSACTION_ID(transaction));
}
-void Database::dropTable(Table * table, Transaction *transaction)
+void Database::dropTable(Table *table, Transaction *transaction)
{
+ Sync syncDDL(&syncSysDDL, "Database::dropTable");
+ syncDDL.lock(Exclusive);
+
table->checkDrop();
// Check for records in active transactions. If so, barf
@@ -1379,8 +1404,8 @@ void Database::dropTable(Table * table,
transactionManager->dropTable(table, transaction);
- Sync sync (&syncTables, "Database::dropTable");
- sync.lock (Exclusive);
+ Sync syncTbl(&syncTables, "Database::dropTable");
+ syncTbl.lock(Exclusive);
// Remove table from linear table list
@@ -1413,9 +1438,7 @@ void Database::dropTable(Table * table,
break;
}
- sync.unlock();
-
- sync.lock(Shared);
+ syncTbl.unlock();
invalidateCompiledStatements(table);
table->drop(transaction);
@@ -1423,8 +1446,11 @@ void Database::dropTable(Table * table,
delete table;
}
-void Database::truncateTable(Table *table, Transaction *transaction)
+void Database::truncateTable(Table *table, Sequence *sequence, Transaction *transaction)
{
+ Sync syncDDL(&syncSysDDL, "Database::truncateTable");
+ syncDDL.lock(Exclusive);
+
table->checkDrop();
// Check for records in active transactions
@@ -1433,38 +1459,34 @@ void Database::truncateTable(Table *tabl
throw SQLError(UNCOMMITTED_UPDATES, "table %s.%s has uncommitted updates and cannot be truncated",
table->schemaName, table->name);
- // Keep scavenger out of the way
-
- Sync scavenge(&table->syncScavenge, "Database::truncateTable");
- scavenge.lock(Shared);
+ // Block table drop/add, table list scans ok
- // Block drop/add, table list scans ok
+ Sync syncTbl(&syncTables, "Database::truncateTable");
+ syncTbl.lock(Shared);
- Sync sync(&syncTables, "Database::truncateTable");
- sync.lock(Shared);
+ // No table access until truncate completes
- // No access until truncate completes
-
- table->deleting = true;
Sync syncObj(&table->syncObject, "Database::truncateTable");
syncObj.lock(Exclusive);
+ table->deleting = true;
+
// Purge records out of committed transactions
transactionManager->truncateTable(table, transaction);
- Sync syncConnection(&syncSysConnection, "Table::truncate");
- syncConnection.lock(Shared);
-
Transaction *sysTransaction = getSystemTransaction();
// Recreate data/blob sections and indexes
table->truncate(sysTransaction);
- syncConnection.unlock();
-
commitSystemTransaction();
+
+ // Delete and recreate the sequence
+
+ if (sequence)
+ sequence = sequence->recreate();
}
void Database::addTable(Table * table)
@@ -1600,14 +1622,19 @@ void Database::invalidateCompiledStateme
ptr = &(*ptr)->next;
}
-
User* Database::createUser(const char * account, const char * password, bool encrypted, Coterie *coterie)
{
+ Sync syncDDL(&syncSysDDL, "Database::createUser");
+ syncDDL.lock(Exclusive);
+
return roleModel->createUser (getSymbol (account), password, encrypted, coterie);
}
User* Database::findUser(const char * account)
{
+ Sync syncDDL(&syncSysDDL, "Database::findUser");
+ syncDDL.lock(Shared);
+
return roleModel->findUser (symbolManager->getSymbol (account));
}
@@ -1618,7 +1645,6 @@ Role* Database::findRole(const char * sc
return roleModel->findRole (schema, role);
}
-
Role* Database::findRole(const WCString *schemaName, const WCString *roleName)
{
return roleModel->findRole (symbolManager->getSymbol (schemaName),
@@ -1627,16 +1653,18 @@ Role* Database::findRole(const WCString
void Database::validate(int optionMask)
{
- Sync sync (&syncObject, "Database::validate");
- sync.lock (Exclusive);
+ Sync syncDDL(&syncSysDDL, "Database::validate");
+ syncDDL.lock(Shared);
+
+ Sync syncObj(&syncObject, "Database::validate");
+ syncObj.lock (Exclusive);
+
Log::debug ("Validation:\n");
dbb->validate (optionMask);
tableSpaceManager->validate(optionMask);
if (optionMask & validateBlobs)
{
- Sync sync2 (&syncSysConnection, "Database::validate");
- sync2.lock (Shared);
PreparedStatement *statement = prepareStatement (
"select tableId,viewDefinition from system.tables");
ResultSet *resultSet = statement->executeQuery();
@@ -1662,8 +1690,9 @@ void Database::scavenge()
// Start by scavenging compiled statements. If they're moldy and not in use,
// off with their heads!
- Sync sync (&syncStatements, "Database::scavenge");
- sync.lock (Exclusive);
+ Sync syncStmt(&syncStatements, "Database::scavenge");
+ syncStmt.lock (Exclusive);
+
time_t threshold = timestamp - STATEMENT_RETIREMENT_AGE;
lastScavenge = timestamp;
@@ -1676,7 +1705,7 @@ void Database::scavenge()
statement->release();
}
- sync.unlock();
+ syncStmt.unlock();
// Next, scavenge tables
@@ -1708,9 +1737,23 @@ void Database::scavenge()
void Database::retireRecords(bool forced)
{
+ Sync syncDDL(&syncSysDDL, "Database::retireRecords");
+ syncDDL.lock(Shared);
+
+ // Commit pending system transactions before proceeding
+
+ if (!forced && systemConnection->transaction)
+ {
+ syncDDL.unlock();
+ if (systemConnection->transaction)
+ commitSystemTransaction();
+ syncDDL.lock(Shared);
+ }
+
+ Sync syncScavenger(&syncScavenge, "Database::retireRecords");
+ syncScavenger.lock(Exclusive);
+
int cycle = scavengeCycle;
- Sync lock(&syncScavenge, "Database::retireRecords");
- lock.lock(Exclusive);
if (forced && scavengeCycle > cycle)
return;
@@ -1720,9 +1763,6 @@ void Database::retireRecords(bool forced
if (forced)
Log::log("Forced record scavenge cycle\n");
- if (!forced && systemConnection->transaction)
- commitSystemTransaction();
-
transactionManager->purgeTransactions();
TransId oldestActiveTransaction = transactionManager->findOldestActive();
int threshold = 0;
@@ -1737,8 +1777,10 @@ void Database::retireRecords(bool forced
{
//LogStream stream;
//recordDataPool->analyze(0, &stream, NULL, NULL);
- Sync syncTbl (&syncTables, "Database::retireRecords");
- syncTbl.lock (Shared);
+
+ Sync syncTbl(&syncTables, "Database::retireRecords");
+ syncTbl.lock(Shared);
+
Table *table;
time_t scavengeStart = deltaTime;
@@ -1770,6 +1812,7 @@ void Database::retireRecords(bool forced
}
syncTbl.unlock();
+
Log::log(LogScavenge, "%d: Scavenged %d records, " I64FORMAT " bytes in %d seconds\n",
deltaTime, recordScavenge.recordsReclaimed, recordScavenge.spaceReclaimed, deltaTime - scavengeStart);
@@ -1865,6 +1908,9 @@ const char* Database::getString(const ch
void Database::upgradeSystemTables()
{
+ Sync syncDDL(&syncSysDDL, "Database::upgradeSystemTables");
+ syncDDL.lock(Shared);
+
for (const char **tableName = changedTables; *tableName; ++tableName)
{
Table *table = findTable("SYSTEM", *tableName);
@@ -1931,7 +1977,7 @@ JString Database::analyze(int mask)
{
Stream stream;
stream.setMalloc (true);
- Sync syncSystemTransaction(&syncSysConnection, "Database::analyze");
+ Sync syncDDL(&syncSysDDL, "Database::analyze");
if (mask & analyzeMemory)
MemMgrAnalyze (mask, &stream);
@@ -1973,8 +2019,8 @@ JString Database::analyze(int mask)
if (mask & analyzeStatements)
{
stream.putSegment ("\nStatements\n");
- Sync sync (&syncStatements, "Database::analyze");
- sync.lock (Shared);
+ Sync syncStmt(&syncStatements, "Database::analyze");
+ syncStmt.lock(Shared);
for (CompiledStatement *statement = compiledStatements; statement;
statement = statement->next)
@@ -1983,12 +2029,12 @@ JString Database::analyze(int mask)
stream.format ("\t(%d)\n", statement->countInstances());
}
stream.putCharacter ('\n');
- sync.unlock();
+ syncStmt.unlock();
}
if (mask & analyzeTables)
{
- syncSystemTransaction.lock(Shared);
+ syncDDL.lock(Shared);
PreparedStatement *statement = prepareStatement (
"select schema,tableName,dataSection,blobSection,tablespace from tables order by schema, tableName");
PreparedStatement *indexQuery = prepareStatement(
@@ -2121,13 +2167,16 @@ Schema* Database::getSchema(const char *
int slot = HASH (name, TABLE_HASH_SIZE);
Schema *schema;
- for (schema = schemas [slot]; schema; schema = schema->collision)
+ Sync syncDDL(&syncSysDDL, "Database::getSchema");
+ syncDDL.lock(Shared);
+
+ for (schema = schemas[slot]; schema; schema = schema->collision)
if (schema->name == name)
return schema;
schema = new Schema (this, name);
- schema->collision = schemas [slot];
- schemas [slot] = schema;
+ schema->collision = schemas[slot];
+ schemas[slot] = schema;
return schema;
}
@@ -2271,10 +2320,12 @@ void Database::getTransactionSummaryInfo
void Database::updateCardinalities(void)
{
- Sync sync (&syncTables, "Database::updateCardinalities");
- sync.lock (Shared);
- Sync syncSystemTransaction(&syncSysConnection, "Database::updateCardinalities");
- syncSystemTransaction.lock(Shared);
+ Sync syncDDL(&syncSysDDL, "Database::updateCardinalities");
+ syncDDL.lock(Shared);
+
+ Sync syncTbl(&syncTables, "Database::updateCardinalities");
+ syncTbl.lock(Shared);
+
bool hit = false;
try
@@ -2306,8 +2357,9 @@ void Database::updateCardinalities(void)
{
}
- sync.unlock();
- syncSystemTransaction.unlock();
+ syncTbl.unlock();
+ syncDDL.unlock();
+
commitSystemTransaction();
}
diff -Nrup a/storage/falcon/Database.h b/storage/falcon/Database.h
--- a/storage/falcon/Database.h 2008-02-20 15:16:03 -06:00
+++ b/storage/falcon/Database.h 2008-03-03 12:40:14 -06:00
@@ -171,7 +171,7 @@ public:
void shutdown();
void execute (const char *sql);
void addTable (Table *table);
- void truncateTable(Table *table, Transaction *transaction);
+ void truncateTable(Table *table, Sequence *sequence, Transaction *transaction);
void dropTable (Table *table, Transaction *transaction);
void flushInversion(Transaction *transaction);
bool matches (const char *fileName);
@@ -259,11 +259,10 @@ public:
SyncObject syncTables;
SyncObject syncStatements; // exclusive lock ok only if syncTables not exclusive
SyncObject syncAddStatement;
- SyncObject syncSysConnection;
SyncObject syncResultSets;
SyncObject syncConnectionStatements;
SyncObject syncScavenge;
- SyncObject syncDDL;
+ SyncObject syncSysDDL;
PriorityScheduler *ioScheduler;
Threads *threads;
Scheduler *scheduler;
diff -Nrup a/storage/falcon/Field.cpp b/storage/falcon/Field.cpp
--- a/storage/falcon/Field.cpp 2007-09-20 10:41:40 -05:00
+++ b/storage/falcon/Field.cpp 2008-03-03 12:40:14 -06:00
@@ -224,8 +224,6 @@ void Field::makeNotSearchable(Transactio
void Field::update()
{
Database *database = table->database;
- Sync sync (&database->syncSysConnection, "Field::update");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"update Fields set flags=?,datatype=?,scale=?,length=?,collationsequence=?,repositoryName=?\n"
@@ -252,7 +250,6 @@ void Field::update()
statement->setString (n++, name);
statement->executeUpdate();
statement->close();
- sync.unlock();
database->commitSystemTransaction();
}
@@ -270,8 +267,6 @@ JdbcType Field::getSqlType()
void Field::save()
{
Database *database = table->database;
- Sync sync (&database->syncSysConnection, "Field::save");
- sync.lock (Shared);
const char *sql = (database->fieldExtensions) ?
"insert Fields (tableName, field, fieldId, datatype, scale, length, flags,schema,collationsequence,repositoryName, precision)"
@@ -312,8 +307,6 @@ void Field::save()
void Field::drop()
{
Database *database = table->database;
- Sync sync (&database->syncSysConnection, "Field::drop");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"delete from Fields where tableName=? and schema=? and field=?");
diff -Nrup a/storage/falcon/FilterSet.cpp b/storage/falcon/FilterSet.cpp
--- a/storage/falcon/FilterSet.cpp 2007-09-20 10:41:41 -05:00
+++ b/storage/falcon/FilterSet.cpp 2008-03-03 12:40:14 -06:00
@@ -99,9 +99,6 @@ void FilterSet::setText(const char *stri
void FilterSet::save()
{
- Sync sync (&database->syncSysConnection, "FilterSet::save");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"replace system.filtersets (filtersetname,schema,text) values (?,?,?)");
statement->setString (1, name);
@@ -109,7 +106,6 @@ void FilterSet::save()
statement->setString (3, sql);
statement->executeUpdate();
statement->close();
- sync.unlock();
database->commitSystemTransaction();
}
diff -Nrup a/storage/falcon/FilterSetManager.cpp b/storage/falcon/FilterSetManager.cpp
--- a/storage/falcon/FilterSetManager.cpp 2007-09-20 10:41:41 -05:00
+++ b/storage/falcon/FilterSetManager.cpp 2008-03-03 12:40:14 -06:00
@@ -82,9 +82,6 @@ FilterSet* FilterSetManager::findFilterS
filterSet->schema == schema)
return filterSet;
- Sync sync (&database->syncSysConnection, "FilterSetManager::findFilterSet");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select text from system.filtersets where filtersetname=? and schema=?");
statement->setString (1, name);
@@ -121,9 +118,6 @@ void FilterSetManager::deleteFilterset(F
*ptr = node->collision;
break;
}
-
- Sync sync (&database->syncSysConnection, "FilterSetManager::deleteFilterset");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"delete from system.filtersets where filtersetname=? and schema=?");
diff -Nrup a/storage/falcon/ForeignKey.cpp b/storage/falcon/ForeignKey.cpp
--- a/storage/falcon/ForeignKey.cpp 2007-09-20 10:41:42 -05:00
+++ b/storage/falcon/ForeignKey.cpp 2008-03-03 12:40:14 -06:00
@@ -107,9 +107,6 @@ ForeignKey::~ForeignKey()
void ForeignKey::save(Database * database)
{
- Sync sync (&database->syncSysConnection, "ForeignKey::save");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"replace into ForeignKeys\
(primaryTableId, primaryFieldId, foreignTableId, foreignFieldId,\
@@ -154,9 +151,6 @@ void ForeignKey::loadRow(Database * data
void ForeignKey::loadPrimaryKeys(Database *database, Table *table)
{
- Sync sync (&database->syncSysConnection, "ForeignKey::loadPrimaryKeys");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select\
primaryTableId, primaryFieldId, foreignTableId, foreignFieldId,\
@@ -193,9 +187,6 @@ void ForeignKey::loadPrimaryKeys(Databas
void ForeignKey::loadForeignKeys(Database *database, Table *table)
{
- Sync sync (&database->syncSysConnection, "ForeignKey::loadForeignKeys");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select\
primaryTableId, primaryFieldId, foreignTableId, foreignFieldId,\
@@ -314,8 +305,6 @@ bool ForeignKey::matches(ForeignKey * ke
void ForeignKey::drop()
{
Database *database = primaryTable->database;
- Sync sync (&database->syncSysConnection, "ForeignKey::drop");
- sync.lock (Shared);
PreparedStatement *statement;
if (foreignTable)
diff -Nrup a/storage/falcon/Format.cpp b/storage/falcon/Format.cpp
--- a/storage/falcon/Format.cpp 2007-09-25 00:14:41 -05:00
+++ b/storage/falcon/Format.cpp 2008-03-03 12:40:14 -06:00
@@ -158,8 +158,6 @@ void Format::save(Table * table)
saved = true;
Database *database = table->database;
- Sync sync (&database->syncSysConnection, "Format::save");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"insert Formats (version, tableId, fieldId, datatype, offset, length, scale, maxId) values (?,?,?,?,?,?,?,?)");
diff -Nrup a/storage/falcon/ImageManager.cpp b/storage/falcon/ImageManager.cpp
--- a/storage/falcon/ImageManager.cpp 2007-09-20 10:41:45 -05:00
+++ b/storage/falcon/ImageManager.cpp 2008-03-03 12:40:14 -06:00
@@ -82,6 +82,9 @@ ImageManager::~ImageManager()
Images* ImageManager::getImages(const char * name, Application *extends)
{
+// Sync syncDDL(&database->syncSysDDL, "ImageManager::getImages");
+// syncDDL.lock(Shared);
+
const char *applicationName = database->getSymbol (name);
int slot = HASH (applicationName, IMAGES_HASH_SIZE);
Images *images;
@@ -216,6 +219,9 @@ void ImageManager::updateCommit(Table *
void ImageManager::checkAccess(Table *table, RecordVersion *recordVersion)
{
+// Sync syncDDL(&database->syncSysDDL, "ImageManager::checkAccess");
+// syncDDL.lock(Shared);
+
if (nameId < 0)
{
nameId = table->getFieldId ("NAME");
diff -Nrup a/storage/falcon/Images.cpp b/storage/falcon/Images.cpp
--- a/storage/falcon/Images.cpp 2007-09-20 10:41:46 -05:00
+++ b/storage/falcon/Images.cpp 2008-03-03 12:40:14 -06:00
@@ -135,8 +135,6 @@ void Images::load()
{
database->commitSystemTransaction();
rehash();
- Sync sync (&database->syncSysConnection, "Images::load");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"select name,alias,width,height from system.images where application=?");
diff -Nrup a/storage/falcon/Index.cpp b/storage/falcon/Index.cpp
--- a/storage/falcon/Index.cpp 2008-01-28 15:01:54 -06:00
+++ b/storage/falcon/Index.cpp 2008-03-03 12:40:14 -06:00
@@ -154,8 +154,6 @@ int Index::matchField(Field * fld)
void Index::save()
{
ASSERT (indexId != -1);
- Sync sync (&database->syncSysConnection, "Index::save");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"insert Indexes (indexName,schema,tableName,indexType,fieldCount,indexId)values(?,?,?,?,?,?);");
@@ -487,9 +485,6 @@ void Index::setIndex(int32 id)
void Index::loadFields()
{
- Sync sync (&database->syncSysConnection, "Index::loadFields");
- sync.lock (Shared);
-
memset (fields, 0, sizeof (Field*) * numberFields);
const char *sql = (database->fieldExtensions) ?
"select field,position,partial,records_per_value from IndexFields where indexName=? and schema=? and tableName=?" :
@@ -623,9 +618,6 @@ bool Index::duplicateKey(IndexKey *key,
JString Index::getTableName(Database *database, const char *schema, const char *indexName)
{
- Sync sync (&database->syncSysConnection, "Index::getTableName");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select tableName from system.indexes where schema=? and indexName=?");
int n = 1;
@@ -645,9 +637,6 @@ JString Index::getTableName(Database *da
void Index::deleteIndex(Database *database, const char *schema, const char *indexName)
{
- Sync sync (&database->syncSysConnection, "Index::deleteIndex");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"delete from system.indexes where schema=? and indexName=?");
int n = 1;
@@ -691,8 +680,6 @@ void Index::rebuildIndex(Transaction *tr
if (damaged)
damageCheck();
- Sync sync (&database->syncSysConnection, "Index::rebuildIndex");
- sync.lock (Shared);
int oldId = indexId;
indexId = dbb->createIndex(TRANSACTION_ID(transaction), indexVersion);
diff -Nrup a/storage/falcon/LicenseManager.cpp b/storage/falcon/LicenseManager.cpp
--- a/storage/falcon/LicenseManager.cpp 2007-09-20 10:41:51 -05:00
+++ b/storage/falcon/LicenseManager.cpp 2008-03-03 12:40:14 -06:00
@@ -144,8 +144,8 @@ LicenseProduct* LicenseManager::getProdu
try
{
- Sync sync (&database->syncSysConnection, "LicenseManager::getProduct");
- sync.lock (Shared);
+ Sync syncDDL(&database->syncSysDDL, "LicenseManager::getProduct");
+ syncDDL.lock(Shared);
PreparedStatement *statement = database->prepareStatement (
"select id,license from system.licenses where product=?");
diff -Nrup a/storage/falcon/Repository.cpp b/storage/falcon/Repository.cpp
--- a/storage/falcon/Repository.cpp 2007-09-20 10:42:15 -05:00
+++ b/storage/falcon/Repository.cpp 2008-03-03 12:40:14 -06:00
@@ -339,8 +339,8 @@ void Repository::setVolume(int volume)
void Repository::save()
{
- Sync sync (&database->syncSysConnection, "Repository::update");
- sync.lock (Shared);
+ Sync syncDDL(&database->syncSysDDL, "Repository::update");
+ syncDDL.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"replace into system.repositories (repositoryName,schema,sequenceName,filename,rollovers,currentVolume)"
"values (?,?,?,?,?,?)");
@@ -353,7 +353,7 @@ void Repository::save()
statement->setInt (n++, currentVolume);
statement->executeUpdate();
statement->close();
- sync.unlock();
+ syncDDL.unlock();
database->commitSystemTransaction();
}
@@ -443,16 +443,13 @@ void Repository::setRollover(const char
void Repository::drop()
{
- Sync sync (&database->syncSysConnection, "Repository::drop");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"delete from system.repositories where schema=? and repositoryName=?");
statement->setString (1, schema);
statement->setString (2, name);
statement->executeUpdate();
statement->close();
- sync.unlock();
+
database->commitSystemTransaction();
}
diff -Nrup a/storage/falcon/RepositoryVolume.cpp b/storage/falcon/RepositoryVolume.cpp
--- a/storage/falcon/RepositoryVolume.cpp 2007-12-19 17:26:16 -06:00
+++ b/storage/falcon/RepositoryVolume.cpp 2008-03-03 12:40:15 -06:00
@@ -233,14 +233,13 @@ void RepositoryVolume::create()
{
IO::createPath (fileName);
dbb->create(fileName, dbb->pageSize, 0, HdrRepositoryFile, 0, NULL, 0);
- Sync syncSystem(&database->syncSysConnection, "RepositoryVolume::create");
+ Sync syncDDL(&database->syncSysDDL, "RepositoryVolume::create");
Transaction *transaction = database->getSystemTransaction();
- syncSystem.lock(Exclusive);
+ syncDDL.lock(Exclusive);
dbb->createIndex(transaction->transactionId, VOLUME_INDEX_VERSION);
dbb->createSection(transaction->transactionId);
- syncSystem.unlock();
+ syncDDL.unlock();
database->commitSystemTransaction();
-
Bdb *bdb = dbb->fetchPage(HEADER_PAGE, PAGE_header, Exclusive);
BDB_HISTORY(bdb);
bdb->mark (0);
diff -Nrup a/storage/falcon/Role.cpp b/storage/falcon/Role.cpp
--- a/storage/falcon/Role.cpp 2007-09-20 10:42:16 -05:00
+++ b/storage/falcon/Role.cpp 2008-03-03 12:40:15 -06:00
@@ -92,9 +92,6 @@ Privilege* Role::getPrivilege(PrivilegeO
if (!database->formatting)
{
- Sync syncConnection (&database->syncSysConnection, "Role::getPrivilege");
- syncConnection.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select privilegeMask from system.privileges where "
"holderType=? and "
diff -Nrup a/storage/falcon/RoleModel.cpp b/storage/falcon/RoleModel.cpp
--- a/storage/falcon/RoleModel.cpp 2007-10-11 07:11:57 -05:00
+++ b/storage/falcon/RoleModel.cpp 2008-03-03 12:40:15 -06:00
@@ -174,8 +174,6 @@ User* RoleModel::createUser(const char *
createTables();
JString encryptedPassword = (encrypted) ? (JString) password : User::encryptPassword (password);
- Sync sync (&database->syncSysConnection, "RoleModel::createUser");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"insert into system.users (username,password,coterie) values (?,?,?)");
@@ -190,9 +188,8 @@ User* RoleModel::createUser(const char *
statement->execute();
statement->close();
- sync.unlock();
-
database->commitSystemTransaction();
+
User *user = new User (database, userName, encryptedPassword, coterie, false);
insertUser (user);
@@ -228,9 +225,6 @@ User* RoleModel::findUser(const char * n
}
***/
- Sync sync (&database->syncSysConnection, "RoleModel::findUser");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select password, coterie from system.users where userName=?");
statement->setString (1, userName);
@@ -298,9 +292,6 @@ Role* RoleModel::findRole(const char * s
if (role->name == name && role->schemaName == schema)
return role;
- Sync sync (&database->syncSysConnection, "RoleModel::findRole");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select roleName from system.roles where schema=? and roleName=?");
statement->setString (1, JString::upcase (schema));
@@ -326,16 +317,12 @@ void RoleModel::createRole(User *owner,
if (!tablesCreated)
createTables();
- Sync sync (&database->syncSysConnection, "RoleModel::createRole");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"insert into system.roles (schema, roleName) values (?,?)");
statement->setString (1, schema);
statement->setString (2, name);
statement->execute();
statement->close();
- sync.unlock();
int slot = HASH (name, ROLE_HASH_SIZE);
Role *role = new Role (database, schema, name);
@@ -344,6 +331,7 @@ void RoleModel::createRole(User *owner,
addUserRole (owner, role, true, 1);
addPrivilege (owner, role, -1);
+
database->commitSystemTransaction();
}
@@ -378,9 +366,6 @@ void RoleModel::addUserPrivilege(User *
void RoleModel::addUserRole(User *user, Role * role, bool defaultRole, int options)
{
- Sync sync (&database->syncSysConnection, "RoleModel::addUserRole");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"replace into system.userRoles"
"(userName,roleSchema,roleName,defaultRole,options) values (?,?,?,?,?)");
@@ -395,7 +380,6 @@ void RoleModel::addUserRole(User *user,
{
statement->executeUpdate();
statement->close();
- sync.unlock();
}
catch (...)
{
@@ -429,9 +413,6 @@ User* RoleModel::getUser(const char * us
bool RoleModel::updatePrivilege(Role * role, PrivilegeObject * object, int32 mask)
{
- Sync sync (&database->syncSysConnection, "RoleModel::updatePrivilege");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"update system.privileges set privilegeMask=? where "
"holderType=? and "
@@ -469,9 +450,6 @@ void RoleModel::changePassword(User *use
if (password)
encryptedPassword = (encrypted) ? (JString) password : User::encryptPassword (password);
- Sync sync (&database->syncSysConnection, "RoleModel::changePassword");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"update system.users set password=?,coterie=? where userName=?");
statement->setString (1, encryptedPassword);
@@ -490,16 +468,12 @@ void RoleModel::changePassword(User *use
if (count < 1)
throw SQLEXCEPTION (DDL_ERROR, "couldn't change password");
- sync.unlock();
database->commitSystemTransaction();
user->changePassword (encryptedPassword);
}
void RoleModel::revokeUserRole(User * user, Role * role)
{
- Sync sync (&database->syncSysConnection, "RoleModel::revokeUserRole");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"delete from system.userRoles where userName=? and roleSchema=? and roleName=?");
int n = 1;
@@ -511,7 +485,6 @@ void RoleModel::revokeUserRole(User * us
{
statement->executeUpdate();
statement->close();
- sync.unlock();
}
catch (...)
{
@@ -528,8 +501,6 @@ void RoleModel::dropRole(Role *role)
if (!tablesCreated)
createTables();
- Sync sync (&database->syncSysConnection, "RoleModel::dropRole");
- sync.lock (Shared);
deletePrivileges (role);
PreparedStatement *statement = database->prepareStatement (
"delete from system.roles where schema=? and roleName=?");
@@ -545,7 +516,6 @@ void RoleModel::dropRole(Role *role)
statement->execute();
statement->close();
- sync.unlock();
database->commitSystemTransaction();
int slot = HASH (role->name, ROLE_HASH_SIZE);
@@ -566,9 +536,6 @@ void RoleModel::dropRole(Role *role)
void RoleModel::insertPrivilege(Role * role, PrivilegeObject * object, int32 mask)
{
- Sync sync (&database->syncSysConnection, "RoleModel::insertPrivilege");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"insert into system.privileges"
"(holderType, holderSchema,holderName,objectType,objectSchema,objectName,privilegeMask)"
@@ -586,7 +553,6 @@ void RoleModel::insertPrivilege(Role * r
{
statement->executeUpdate();
statement->close();
- sync.unlock();
}
catch (...)
{
@@ -612,8 +578,6 @@ void RoleModel::removePrivilege(Role *ro
void RoleModel::dropObject(PrivilegeObject *object)
{
PrivObject type = object->getPrivilegeType();
- Sync sync (&database->syncSysConnection, "RoleModel::dropObject");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"delete from system.privileges where objectType=? and objectSchema=? and objectName=?");
@@ -633,8 +597,6 @@ void RoleModel::dropObject(PrivilegeObje
throw;
}
- sync.unlock();
-
for (n = 0; n < ROLE_HASH_SIZE; ++n)
for (Role *role = roles [n]; role; role = role->collision)
role->dropObject (object);
@@ -658,9 +620,6 @@ Coterie* RoleModel::findCoterie(const ch
if (coterie->name == name)
return coterie;
- Sync sync (&database->syncSysConnection, "RoleModel::findCoterie");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select ip_start,ip_end from system.coteries where coterie=?");
statement->setString (1, name);
@@ -715,9 +674,6 @@ void RoleModel::insertCoterie(Coterie *c
void RoleModel::updateCoterie(Coterie *coterie)
{
#ifndef STORAGE_ENGINE
- Sync sync (&database->syncSysConnection, "RoleModel::updateCoterie");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"delete from system.coteries where coterie=?");
statement->setString (1, coterie->name);
@@ -736,7 +692,6 @@ void RoleModel::updateCoterie(Coterie *c
statement->executeUpdate();
}
- sync.unlock();
database->commitSystemTransaction();
statement->close();
#endif
@@ -745,9 +700,6 @@ void RoleModel::updateCoterie(Coterie *c
void RoleModel::dropCoterie(Coterie *coterie)
{
#ifndef STORAGE_ENGINE
- Sync sync (&database->syncSysConnection, "RoleModel::dropCoterie");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select username from system.users where coterie=?");
statement->setString (1, coterie->name);
@@ -773,15 +725,13 @@ void RoleModel::dropCoterie(Coterie *cot
break;
}
- sync.unlock();
dropObject (coterie);
- sync.lock (Shared);
statement = database->prepareStatement (
"delete from system.coteries where coterie=?");
statement->setString (1, coterie->name);
statement->execute();
statement->close();
- sync.unlock();
+
database->commitSystemTransaction();
delete coterie;
@@ -800,15 +750,13 @@ void RoleModel::dropUser(User *user)
break;
}
- Sync sync (&database->syncSysConnection, "RoleModel::dropUser");
- sync.lock (Shared);
deletePrivileges (user);
PreparedStatement *statement = database->prepareStatement (
"delete from system.users where username=?");
statement->setString (1, user->name);
statement->execute();
statement->close();
- sync.unlock();
+
database->commitSystemTransaction();
user->release();
diff -Nrup a/storage/falcon/Scheduler.cpp b/storage/falcon/Scheduler.cpp
--- a/storage/falcon/Scheduler.cpp 2007-09-20 10:42:31 -05:00
+++ b/storage/falcon/Scheduler.cpp 2008-03-03 12:40:15 -06:00
@@ -185,8 +185,8 @@ void Scheduler::start()
initialize();
#ifndef STORAGE_ENGINE
- Sync sync (&database->syncSysConnection, "Scheduler::start");
- sync.lock (Shared);
+ Sync syncDDL(&database->syncSysDDL, "Scheduler::start");
+ syncDDL.lock(Shared);
PreparedStatement *statement = database->prepareStatement (
"select application, eventName from system.schedule");
@@ -210,8 +210,8 @@ void Scheduler::start()
void Scheduler::updateSchedule(const char *appName, const char *eventName, User *user, const char *schedule)
{
- Sync sync (&syncObject, "Scheduler::updateSchedule");
- sync.lock (Exclusive);
+ Sync syncObj(&syncObject, "Scheduler::updateSchedule");
+ syncObj.lock(Exclusive);
// Ditch old event
@@ -227,8 +227,8 @@ void Scheduler::updateSchedule(const cha
// If no schedule, we're done
- Sync syncConnection (&database->syncSysConnection, "Scheduler::updateSchedule(2)");
- syncConnection.lock (Exclusive);
+ Sync syncDDL (&database->syncSysDDL, "Scheduler::updateSchedule(2)");
+ syncDDL.lock (Exclusive);
if (!schedule || !schedule[0])
{
@@ -238,8 +238,8 @@ void Scheduler::updateSchedule(const cha
statement->setString (2, eventName);
statement->executeUpdate();
statement->close();
- syncConnection.unlock();
- sync.unlock();
+ syncDDL.unlock();
+ syncObj.unlock();
database->commitSystemTransaction();
return;
}
@@ -253,10 +253,10 @@ void Scheduler::updateSchedule(const cha
statement->setString (n++, schedule);
statement->executeUpdate();
statement->close();
- syncConnection.unlock();
- sync.unlock();
+ syncDDL.unlock();
+ syncObj.unlock();
database->commitSystemTransaction();
- sync.lock (Exclusive);
+ //syncObj.lock (Exclusive);
#ifndef STORAGE_ENGINE
Application *application = database->getApplication (appName);
@@ -298,8 +298,8 @@ void Scheduler::loadEvents(Application *
initialize();
#ifndef STORAGE_ENGINE
- Sync sync (&database->syncSysConnection, "Scheduler::loadEvents");
- sync.lock (Shared);
+ Sync syncDDL(&database->syncSysDDL, "Scheduler::loadEvents");
+ syncDDL.lock(Shared);
PreparedStatement *statement = database->prepareStatement (
"select * from system.schedule where application=?");
diff -Nrup a/storage/falcon/Schema.cpp b/storage/falcon/Schema.cpp
--- a/storage/falcon/Schema.cpp 2007-09-20 10:42:31 -05:00
+++ b/storage/falcon/Schema.cpp 2008-03-03 12:40:15 -06:00
@@ -45,8 +45,6 @@ Schema::~Schema()
void Schema::update()
{
- Sync sync (&database->syncSysConnection, "Schema::update");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"replace system.schemas (schema,sequence_interval,system_id) values (?,?,?)");
int n = 1;
@@ -54,7 +52,7 @@ void Schema::update()
statement->setInt (n++, sequenceInterval);
statement->setInt (n++, systemId);
statement->executeUpdate();
- sync.unlock();
+
database->commitSystemTransaction();
}
@@ -78,8 +76,6 @@ void Schema::setSystemId(int newId)
void Schema::refresh()
{
- Sync sync (&database->syncSysConnection, "Schema::refresh");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"select sequence_interval, system_id from system.schemas where schema=?");
statement->setString (1, name);
diff -Nrup a/storage/falcon/SequenceManager.cpp b/storage/falcon/SequenceManager.cpp
--- a/storage/falcon/SequenceManager.cpp 2007-11-13 16:09:36 -06:00
+++ b/storage/falcon/SequenceManager.cpp 2008-03-03 12:40:15 -06:00
@@ -72,9 +72,6 @@ void SequenceManager::initialize()
for (const char **p = ddl; *p; ++p)
database->execute (*p);
- Sync sync (&database->syncSysConnection, "SequenceManager::initialize");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select schema, sequenceName, id from system.sequences");
ResultSet *resultSet = statement->executeQuery();
@@ -116,8 +113,6 @@ Sequence* SequenceManager::createSequenc
{
int id = database->createSequence (initialValue);
Sequence *sequence = new Sequence (database, schema, name, id);
- Sync sync (&database->syncSysConnection, "SequenceManager::createSequence");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"insert into system.sequences (schema,sequenceName,id) values (?,?,?)");
@@ -125,12 +120,12 @@ Sequence* SequenceManager::createSequenc
statement->setString (2, sequence->name);
statement->setLong(3, sequence->id);
statement->executeUpdate();
- sync.unlock();
statement->close();
+
database->commitSystemTransaction();
- sync.setObject (&syncObject);
- sync.lock (Exclusive);
+ Sync syncObj(&syncObject, "SequenceManager::createSequence");
+ syncObj.lock (Exclusive);
int slot = HASH (sequence->name, SEQUENCE_HASH_SIZE);
ASSERT (slot >= 0 && slot < SEQUENCE_HASH_SIZE);
sequence->collision = sequences [slot];
@@ -150,21 +145,18 @@ Sequence* SequenceManager::recreateSeque
void SequenceManager::deleteSequence(const char *schema, const char *name)
{
- Sync sync (&database->syncSysConnection, "SequenceManager::deleteSequence");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"delete from system.sequences where schema=? and sequenceName=?");
statement->setString (1, schema);
statement->setString (2, name);
statement->executeUpdate();
statement->close();
- sync.unlock();
+
database->commitSystemTransaction();
int slot = HASH (name, SEQUENCE_HASH_SIZE);
- sync.setObject (&syncObject);
- sync.lock (Exclusive);
+ Sync syncObj(&syncObject, "SequenceManager::deleteSequence");
+ syncObj.lock (Exclusive);
for (Sequence *sequence, **ptr = sequences + slot; (sequence = *ptr); ptr = &sequence->collision)
if (sequence->schemaName == schema && sequence->name == name)
diff -Nrup a/storage/falcon/Statement.cpp b/storage/falcon/Statement.cpp
--- a/storage/falcon/Statement.cpp 2008-02-20 15:16:03 -06:00
+++ b/storage/falcon/Statement.cpp 2008-03-03 12:40:15 -06:00
@@ -221,13 +221,10 @@ void Statement::createTable(Syntax * syn
if (!database->formatting)
{
- Sync sync (&database->syncSysConnection, "Statement::createTable");
- sync.lock(Exclusive);
Transaction *sysTransaction = database->getSystemTransaction();
table->create ((connection == database->systemConnection) ? "SYSTEM TABLE" : "TABLE", sysTransaction);
table->save();
database->roleModel->addUserPrivilege (connection->user, table, ALL_PRIVILEGES);
- sync.unlock();
database->commitSystemTransaction();
}
@@ -250,9 +247,6 @@ void Statement::createIndex(Syntax * syn
if (!database->formatting)
{
- Sync sync (&database->syncSysConnection, "Statement::createIndex");
- sync.lock (Shared);
-
PreparedStatement *check = database->prepareStatement (
"select tableName from system.indexes where schema=? and indexName=?");
check->setString (1, table->schemaName);
@@ -712,8 +706,8 @@ void Statement::executeDDL()
ASSERT (syntax);
Syntax *child;
- Sync sync(&database->syncDDL, "Statement::executeDDL");
- sync.lock(Exclusive);
+ Sync syncDDL(&database->syncSysDDL, "Statement::executeDDL");
+ syncDDL.lock(Exclusive);
switch (syntax->type)
{
@@ -2831,8 +2825,6 @@ void Statement::dropRepository(Syntax *s
const char *name = getName (node);
const char *schema = getSchemaName (node);
Repository *repository = database->getRepository (schema, name);
- Sync sync (&database->syncSysConnection, "Statement::dropRepository");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"select field,tableName from system.fields where schema=? and repositoryName=?");
@@ -2851,7 +2843,6 @@ void Statement::dropRepository(Syntax *s
name, (const char*) fieldName, (const char*) tableName);
}
- sync.unlock();
resultSet->close();
statement->close();
database->deleteRepository (repository);
@@ -2965,9 +2956,6 @@ void Statement::dropTableSpace(Syntax* s
if (!tableSpace)
throw SQLError(TABLESPACE_NOT_EXIST_ERROR, "table space \"%s\" is not defined", name);
- Sync sync (&database->syncSysConnection, "Statement::createIndex");
- sync.lock (Shared);
-
PStatement statement = database->prepareStatement (
"select * from system.tables where tablespace=?");
statement->setString (1, name);
@@ -2978,6 +2966,6 @@ void Statement::dropTableSpace(Syntax* s
resultSet.close();
statement.close();
- sync.unlock();
+
tableSpaceManager->dropTableSpace(tableSpace);
}
diff -Nrup a/storage/falcon/StorageDatabase.cpp b/storage/falcon/StorageDatabase.cpp
--- a/storage/falcon/StorageDatabase.cpp 2008-02-29 23:32:07 -06:00
+++ b/storage/falcon/StorageDatabase.cpp 2008-03-03 12:40:15 -06:00
@@ -529,16 +529,12 @@ int StorageDatabase::truncateTable(Stora
Connection *connection = storageConnection->connection;
Transaction *transaction = connection->transaction;
Database *database = connection->database;
- Sequence *sequence = tableShare->sequence;
int res = 0;
try
{
- database->truncateTable(tableShare->table, transaction);
-
- if (sequence)
- sequence = sequence->recreate();
+ database->truncateTable(tableShare->table, tableShare->sequence, transaction);
}
catch (SQLException& exception)
{
@@ -682,15 +678,12 @@ int StorageDatabase::renameTable(Storage
++numberIndexes;
}
- Sync syncDDL (&database->syncDDL, "StorageDatabase::renameTable");
+ Sync syncDDL(&database->syncSysDDL, "StorageDatabase::renameTable");
syncDDL.lock(Exclusive);
- Sync syncTables (&database->syncTables, "StorageDatabase::renameTable");
- syncTables.lock (Exclusive);
+ Sync syncTables(&database->syncTables, "StorageDatabase::renameTable");
+ syncTables.lock(Exclusive);
- Sync syncSysConn(&database->syncSysConnection, "StorageDatabase::renameTable");
- syncSysConn.lock(Exclusive);
-
for (int n = firstIndex; n < numberIndexes; ++n)
{
char indexName[256];
@@ -709,7 +702,6 @@ int StorageDatabase::renameTable(Storage
if (sequence)
sequence->rename(tableName);
- syncSysConn.unlock();
syncTables.unlock();
syncDDL.unlock();
diff -Nrup a/storage/falcon/Table.cpp b/storage/falcon/Table.cpp
--- a/storage/falcon/Table.cpp 2008-02-28 12:18:32 -06:00
+++ b/storage/falcon/Table.cpp 2008-03-03 12:40:15 -06:00
@@ -213,9 +213,6 @@ void Table::create(const char * tableTyp
void Table::save()
{
- Sync sync(&database->syncSysConnection, "Table::save");
- sync.lock(Shared);
-
PreparedStatement *statement = database->prepareStatement(
(database->fieldExtensions) ?
"insert Tables (tableName,tableId,dataSection,blobSection,currentVersion,type,schema,viewDefinition,tablespace) values (?,?,?,?,?,?,?,?,?);" :
@@ -251,8 +248,6 @@ void Table::save()
field->save();
END_FOR;
- sync.unlock();
-
if (view)
view->save(database);
else
@@ -397,11 +392,11 @@ Format* Table::getFormat(int version)
if (format->version == version)
return format;
- Sync sync(&syncObject, "Table::getFormat");
- sync.lock(Exclusive);
+ Sync syncObj(&syncObject, "Table::getFormat");
+ syncObj.lock(Exclusive);
- Sync sync2(&database->syncSysConnection, "Table::save");
- sync2.lock(Shared);
+ Sync syncDDL(&database->syncSysDDL, "Table::getFormat");
+ syncDDL.lock(Shared);
PStatement statement = database->prepareStatement(
"select version, fieldId, dataType, offset, length, scale, maxId from system.Formats where tableId=? and version=?");
@@ -409,7 +404,7 @@ Format* Table::getFormat(int version)
statement->setInt(2, version);
RSet set = statement->executeQuery();
format = NEW Format(this, set);
- sync2.unlock();
+ syncDDL.unlock();
addFormat(format);
return format;
@@ -431,9 +426,6 @@ void Table::reformat()
if (!database->formatting)
{
format->save(this);
- Sync sync(&database->syncSysConnection, "Table::reformat");
- sync.lock(Shared);
-
PreparedStatement *statement = database->prepareStatement(
"update Tables set currentVersion=? where tableName=? and schema=?");
int n = 1;
@@ -680,9 +672,6 @@ void Table::setBlobSection(int32 section
void Table::loadFields()
{
- Sync sync (&database->syncSysConnection, "Table::loadFields");
- sync.lock (Shared);
-
const char *sql = (database->fieldExtensions) ?
"select field,fieldId,dataType,length,scale,flags,collationsequence,repositoryName,domainName,precision"
" from system.Fields where tableName=? and schema=?" :
@@ -734,9 +723,6 @@ void Table::loadFields()
void Table::loadIndexes()
{
- Sync sync (&database->syncSysConnection, "Table::loadIndexes");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select indexName,indexType,indexId,fieldCount from system.Indexes where tableName=? and schema=?");
statement->setString (1, name);
@@ -1469,9 +1455,6 @@ void Table::drop(Transaction *transactio
}
- Sync sync(&database->syncSysConnection, "Table::drop");
- sync.lock(Shared);
-
Transaction *sysTransaction = database->getSystemTransaction();
for (Index *index = indexes; index; index = index->next)
@@ -1505,8 +1488,6 @@ void Table::drop(Transaction *transactio
if (view)
view->drop(database);
- sync.unlock();
-
database->commitSystemTransaction();
}
@@ -1712,10 +1693,8 @@ int Table::retireRecords(RecordScavenge
if (!records)
return 0;
- Sync scavenge(&syncScavenge, "Table::retireRecords");
- scavenge.lock(Exclusive);
- Sync sync(&syncObject, "Table::retireRecords");
- sync.lock(Shared);
+ Sync syncObj(&syncObject, "Table::retireRecords");
+ syncObj.lock(Shared);
if (!records)
return 0;
@@ -1726,8 +1705,8 @@ int Table::retireRecords(RecordScavenge
if (count == 0)
{
- sync.unlock();
- sync.lock(Exclusive);
+ syncObj.unlock();
+ syncObj.lock(Exclusive);
// Confirm that tree is still empty
@@ -1746,8 +1725,8 @@ int Table::retireRecords(RecordScavenge
if (emptySections->count > 0)
{
- sync.unlock();
- sync.lock(Exclusive);
+ syncObj.unlock();
+ syncObj.lock(Exclusive);
for (int recordNumber = 0; (recordNumber = emptySections->nextSet(recordNumber)) >= 0;)
{
@@ -2776,8 +2755,6 @@ void Table::deleteRecord(int recordNumbe
void Table::refreshFields()
{
- Sync sync(&database->syncSysConnection, "Table::loadFields");
- sync.lock(Shared);
const char *sql = (database->fieldExtensions) ?
"select field, fieldId, dataType, length, scale, flags, collationsequence, precision\
from system.Fields where tableName=? and schema=?" :
@@ -3090,9 +3067,6 @@ void Table::update(Transaction * transac
void Table::rename(const char *newSchema, const char *newName)
{
- Sync sync(&database->syncSysConnection, "Statement::renameTables");
- sync.lock(Exclusive);
-
try
{
for (const char **tbl = relatedTables; *tbl; ++tbl)
@@ -3112,7 +3086,6 @@ void Table::rename(const char *newSchema
}
database->commitSystemTransaction();
- sync.unlock();
Index *primaryKey = getPrimaryKey();
database->renameTable(this, newSchema, newName);
diff -Nrup a/storage/falcon/TableSpaceManager.cpp b/storage/falcon/TableSpaceManager.cpp
--- a/storage/falcon/TableSpaceManager.cpp 2008-02-28 11:19:48 -06:00
+++ b/storage/falcon/TableSpaceManager.cpp 2008-03-03 12:40:15 -06:00
@@ -83,23 +83,24 @@ void TableSpaceManager::add(TableSpace *
TableSpace* TableSpaceManager::findTableSpace(const char *name)
{
- Sync sync(&syncObject, "TableSpaceManager::findTableSpace");
- sync.lock(Shared);
+ Sync syncObj(&syncObject, "TableSpaceManager::findTableSpace");
+ syncObj.lock(Shared);
TableSpace *tableSpace;
for (tableSpace = nameHash[JString::hash(name, TS_HASH_SIZE)]; tableSpace; tableSpace = tableSpace->nameCollision)
if (tableSpace->name == name)
return tableSpace;
- sync.unlock();
- sync.lock(Exclusive);
+ syncObj.unlock();
+ syncObj.lock(Exclusive);
for (tableSpace = nameHash[JString::hash(name, TS_HASH_SIZE)]; tableSpace; tableSpace = tableSpace->nameCollision)
if (tableSpace->name == name)
return tableSpace;
- Sync syncSystem (&database->syncSysConnection, "TableSpaceManager::findTableSpace");
- syncSystem.lock (Shared);
+ Sync syncDDL(&database->syncSysDDL, "TableSpaceManager::findTableSpace");
+ syncDDL.lock(Shared);
+
PStatement statement = database->prepareStatement(
"select tablespace_id,filename,status from system.tablespaces where tablespace=?");
statement->setString(1, name);
@@ -145,8 +146,8 @@ TableSpace* TableSpaceManager::getTableS
TableSpace* TableSpaceManager::createTableSpace(const char *name, const char *fileName, uint64 initialAllocation, bool repository)
{
- Sync syncSystem(&database->syncSysConnection, "TableSpaceManager::createTableSpace");
- syncSystem.lock(Shared);
+ Sync syncDDL(&database->syncSysDDL, "TableSpaceManager::createTableSpace");
+ syncDDL.lock(Shared);
Sequence *sequence = database->sequenceManager->getSequence(database->getSymbol("SYSTEM"), database->getSymbol("TABLESPACE_IDS"));
int type = (repository) ? TABLESPACE_TYPE_REPOSITORY : TABLESPACE_TYPE_TABLESPACE;
int id = (int) sequence->update(1, database->getSystemTransaction());
@@ -165,7 +166,7 @@ TableSpace* TableSpaceManager::createTab
if (!repository)
tableSpace->create();
- syncSystem.unlock();
+ syncDDL.unlock();
database->commitSystemTransaction();
add(tableSpace);
}
@@ -201,7 +202,7 @@ void TableSpaceManager::bootstrap(int se
p = EncodedDataStream::decode(p, &fileName, true);
p = EncodedDataStream::decode(p, &status, true);
TableSpace *tableSpace = new TableSpace(database, name.getString(), id.getInt(), fileName.getString(), 0, status.getInt());
- Log::debug("New Table space %s, id %d, type %d, filename %s\n", (const char*) tableSpace->name, tableSpace->tableSpaceId, tableSpace->type, (const char*) tableSpace->filename);
+ Log::debug("New table space %s, id %d, type %d, filename %s\n", (const char*) tableSpace->name, tableSpace->tableSpaceId, tableSpace->type, (const char*) tableSpace->filename);
if (tableSpace->type == TABLESPACE_TYPE_TABLESPACE)
try
@@ -257,10 +258,12 @@ void TableSpaceManager::dropDatabase(voi
void TableSpaceManager::dropTableSpace(TableSpace* tableSpace)
{
- Sync sync(&syncObject, "TableSpaceManager::dropTableSpace");
- sync.lock(Exclusive);
- Sync syncSystem(&database->syncSysConnection, "TableSpaceManager::dropTableSpace");
- syncSystem.lock(Shared);
+ Sync syncObj(&syncObject, "TableSpaceManager::dropTableSpace");
+ syncObj.lock(Exclusive);
+
+ Sync syncDDL(&database->syncSysDDL, "TableSpaceManager::dropTableSpace");
+ syncDDL.lock(Shared);
+
PStatement statement = database->prepareStatement(
"delete from system.tablespaces where tablespace=?");
statement->setString(1, tableSpace->name);
@@ -268,8 +271,10 @@ void TableSpaceManager::dropTableSpace(T
Transaction *transaction = database->getSystemTransaction();
transaction->hasUpdates = true;
database->serialLog->logControl->dropTableSpace.append(tableSpace, transaction);
- syncSystem.unlock();
+
+ syncDDL.unlock();
database->commitSystemTransaction();
+
int slot = tableSpace->name.hash(TS_HASH_SIZE);
for (TableSpace **ptr = nameHash + slot; *ptr; ptr = &(*ptr)->nameCollision)
@@ -280,7 +285,7 @@ void TableSpaceManager::dropTableSpace(T
break;
}
- sync.unlock();
+ syncObj.unlock();
tableSpace->active = false;
}
@@ -402,16 +407,16 @@ void TableSpaceManager::redoCreateTableS
void TableSpaceManager::initialize(void)
{
- Sync sync(&syncObject, "TableSpaceManager::initialize");
- sync.lock(Shared);
+ Sync syncObj(&syncObject, "TableSpaceManager::initialize");
+ syncObj.lock(Shared);
for (TableSpace *tableSpace = tableSpaces; tableSpace; tableSpace = tableSpace->next)
if (tableSpace->needSave)
{
- Sync syncSystem(&database->syncSysConnection, "TableSpaceManager::dropTableSpace");
- syncSystem.lock(Shared);
+ Sync syncDDL(&database->syncSysDDL, "TableSpaceManager::dropTableSpace");
+ syncDDL.lock(Shared);
tableSpace->save();
- syncSystem.unlock();
+ syncDDL.unlock();
database->commitSystemTransaction();
}
}
diff -Nrup a/storage/falcon/Trigger.cpp b/storage/falcon/Trigger.cpp
--- a/storage/falcon/Trigger.cpp 2007-09-20 10:42:46 -05:00
+++ b/storage/falcon/Trigger.cpp 2008-03-03 12:40:15 -06:00
@@ -122,9 +122,6 @@ void Trigger::loadClass()
void Trigger::save()
{
- Sync sync (&database->syncSysConnection, "Trigger::save");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"replace into system.triggers "
"(schema,triggerName,tableName,type_mask,position,active,classname,methodname)"
@@ -160,8 +157,6 @@ void Trigger::save()
void Trigger::getTableTriggers(Table *table)
{
Database *database = table->database;
- Sync sync (&database->syncSysConnection, "Trigger::getTableTriggers");
- sync.lock (Shared);
PreparedStatement *statement = database->prepareStatement (
"select triggerName,type_mask,position,active,classname,methodname "
@@ -255,9 +250,6 @@ void Trigger::fireTrigger(Transaction *t
JString Trigger::getTableName(Database *database, const char *schema, const char *name)
{
- Sync sync (&database->syncSysConnection, "Trigger::getTableName");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"select tableName from system.triggers where schema=? and triggerName=?");
int n = 1;
@@ -285,9 +277,6 @@ void Trigger::deleteTrigger()
void Trigger::deleteTrigger(Database *database, const char *schema, const char *name)
{
- Sync sync (&database->syncSysConnection, "Trigger::deleteTrigger");
- sync.lock (Shared);
-
PreparedStatement *statement = database->prepareStatement (
"delete from system.triggers where schema=? and triggerName=?");
int n = 1;
| Thread |
|---|
| • bk commit into 6.0 tree (cpowers:1.2586) BUG#34567 | cpowers | 3 Mar |