Commit 2c98bb11 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1832, #1821

pre-acquire a table lock before attempting a truncate in the handlerton

git-svn-id: file:///svn/mysql/tokudb-engine/src@12985 c7de825b-a66e-492c-adef-691d508d4ae1
parent fa63f152
...@@ -5631,24 +5631,35 @@ int ha_tokudb::delete_all_rows() { ...@@ -5631,24 +5631,35 @@ int ha_tokudb::delete_all_rows() {
TOKUDB_DBUG_ENTER("delete_all_rows"); TOKUDB_DBUG_ENTER("delete_all_rows");
int error = 0; int error = 0;
//
// prelock so we know right away if there are any potential
// deadlocks
//
error = acquire_table_lock(transaction, lock_write);
if (error) {
goto cleanup;
}
// truncate all dictionaries // truncate all dictionaries
uint curr_num_DBs = table->s->keys + test(hidden_primary_key); uint curr_num_DBs = table->s->keys + test(hidden_primary_key);
for (uint i = 0; i < curr_num_DBs; i++) { for (uint i = 0; i < curr_num_DBs; i++) {
DB *db = share->key_file[i]; DB *db = share->key_file[i];
u_int32_t row_count = 0; u_int32_t row_count = 0;
error = db->truncate(db, transaction, &row_count, 0); error = db->truncate(db, transaction, &row_count, 0);
if (error) if (error) {
break; break;
}
// do something with the row_count? // do something with the row_count?
if (tokudb_debug) if (tokudb_debug) {
TOKUDB_TRACE("row_count=%u\n", row_count); TOKUDB_TRACE("row_count=%u\n", row_count);
}
} }
// zap the row count // zap the row count
if (error == 0) if (error == 0) {
share->rows = 0; share->rows = 0;
}
cleanup:
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment