Commit 84b982ba authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #922

back out change for 4591, need more testing before it can go in
reopening ticket

git-svn-id: file:///svn/mysql/tokudb-engine/src@4634 c7de825b-a66e-492c-adef-691d508d4ae1
parent 37d2b97c
...@@ -2188,12 +2188,6 @@ int ha_tokudb::delete_row(const uchar * record) { ...@@ -2188,12 +2188,6 @@ int ha_tokudb::delete_row(const uchar * record) {
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
//
// Macro to test if read_lock is already grabbed
//
#define READ_LOCK_GRABBED() (range_lock_grabbed || (lock.type == TL_READ_NO_INSERT) || (lock.type == TL_WRITE))
// //
// Initializes local cursor on DB with index keynr // Initializes local cursor on DB with index keynr
// Parameters: // Parameters:
...@@ -2573,7 +2567,7 @@ int ha_tokudb::index_next(uchar * buf) { ...@@ -2573,7 +2567,7 @@ int ha_tokudb::index_next(uchar * buf) {
TOKUDB_DBUG_ENTER("ha_tokudb::index_next"); TOKUDB_DBUG_ENTER("ha_tokudb::index_next");
int error; int error;
DBT row; DBT row;
u_int32_t flags = READ_LOCK_GRABBED() ? (DB_NEXT | DB_PRELOCKED) : DB_NEXT; u_int32_t flags = range_lock_grabbed ? (DB_NEXT | DB_PRELOCKED) : DB_NEXT;
CHECK_VALID_CURSOR(); CHECK_VALID_CURSOR();
statistic_increment(table->in_use->status_var.ha_read_next_count, &LOCK_status); statistic_increment(table->in_use->status_var.ha_read_next_count, &LOCK_status);
...@@ -2607,11 +2601,11 @@ int ha_tokudb::index_next_same(uchar * buf, const uchar * key, uint keylen) { ...@@ -2607,11 +2601,11 @@ int ha_tokudb::index_next_same(uchar * buf, const uchar * key, uint keylen) {
!(table->key_info[active_index].flags & HA_NOSAME) && !(table->key_info[active_index].flags & HA_NOSAME) &&
!(table->key_info[active_index].flags & HA_END_SPACE_KEY)) { !(table->key_info[active_index].flags & HA_END_SPACE_KEY)) {
u_int32_t flags = READ_LOCK_GRABBED() ? (DB_NEXT_DUP | DB_PRELOCKED) : DB_NEXT_DUP; u_int32_t flags = range_lock_grabbed ? (DB_NEXT_DUP | DB_PRELOCKED) : DB_NEXT_DUP;
error = cursor->c_get(cursor, &last_key, &row, flags); error = cursor->c_get(cursor, &last_key, &row, flags);
error = read_row(error, buf, active_index, &row, &last_key, 1); error = read_row(error, buf, active_index, &row, &last_key, 1);
} else { } else {
u_int32_t flags = READ_LOCK_GRABBED() ? (DB_NEXT | DB_PRELOCKED) : DB_NEXT; u_int32_t flags = range_lock_grabbed ? (DB_NEXT | DB_PRELOCKED) : DB_NEXT;
error = read_row(cursor->c_get(cursor, &last_key, &row, flags), buf, active_index, &row, &last_key, 1); error = read_row(cursor->c_get(cursor, &last_key, &row, flags), buf, active_index, &row, &last_key, 1);
if (!error &&::key_cmp_if_same(table, key, active_index, keylen)) if (!error &&::key_cmp_if_same(table, key, active_index, keylen))
error = HA_ERR_END_OF_FILE; error = HA_ERR_END_OF_FILE;
...@@ -2632,7 +2626,7 @@ cleanup: ...@@ -2632,7 +2626,7 @@ cleanup:
int ha_tokudb::index_prev(uchar * buf) { int ha_tokudb::index_prev(uchar * buf) {
TOKUDB_DBUG_ENTER("ha_tokudb::index_prev"); TOKUDB_DBUG_ENTER("ha_tokudb::index_prev");
int error; int error;
u_int32_t flags = READ_LOCK_GRABBED() ? (DB_PREV | DB_PRELOCKED) : DB_PREV; u_int32_t flags = range_lock_grabbed ? (DB_PREV | DB_PRELOCKED) : DB_PREV;
CHECK_VALID_CURSOR(); CHECK_VALID_CURSOR();
DBT row; DBT row;
statistic_increment(table->in_use->status_var.ha_read_prev_count, &LOCK_status); statistic_increment(table->in_use->status_var.ha_read_prev_count, &LOCK_status);
...@@ -2739,7 +2733,7 @@ int ha_tokudb::rnd_next(uchar * buf) { ...@@ -2739,7 +2733,7 @@ int ha_tokudb::rnd_next(uchar * buf) {
TOKUDB_DBUG_ENTER("ha_tokudb::ha_tokudb::rnd_next"); TOKUDB_DBUG_ENTER("ha_tokudb::ha_tokudb::rnd_next");
int error; int error;
DBT row; DBT row;
u_int32_t flags = READ_LOCK_GRABBED() ? (DB_NEXT | DB_PRELOCKED) : DB_NEXT; u_int32_t flags = range_lock_grabbed ? (DB_NEXT | DB_PRELOCKED) : DB_NEXT;
CHECK_VALID_CURSOR() CHECK_VALID_CURSOR()
// //
...@@ -3049,24 +3043,6 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { ...@@ -3049,24 +3043,6 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
trans_register_ha(thd, FALSE, tokudb_hton); trans_register_ha(thd, FALSE, tokudb_hton);
} }
transaction = trx->stmt; transaction = trx->stmt;
//
// pre-acquire locks if possible
//
uint curr_num_DBs = table->s->keys + test(hidden_primary_key);
if (lock.type == TL_READ_NO_INSERT) {
for (uint i = 0; i < curr_num_DBs; i++) {
DB* db = share->key_file[i];
error = db->pre_acquire_read_lock(db, transaction, db->dbt_neg_infty(), NULL, db->dbt_pos_infty(), NULL);
if (error) { TOKUDB_DBUG_RETURN(error); }
}
}
else if (lock.type == TL_WRITE) {
for (uint i = 0; i < curr_num_DBs; i++) {
DB* db = share->key_file[i];
error = db->pre_acquire_table_lock(db, transaction);
if (error) { TOKUDB_DBUG_RETURN(error); }
}
}
} }
else { else {
lock.type = TL_UNLOCK; // Unlocked lock.type = TL_UNLOCK; // Unlocked
...@@ -3150,7 +3126,7 @@ THR_LOCK_DATA **ha_tokudb::store_lock(THD * thd, THR_LOCK_DATA ** to, enum thr_l ...@@ -3150,7 +3126,7 @@ THR_LOCK_DATA **ha_tokudb::store_lock(THD * thd, THR_LOCK_DATA ** to, enum thr_l
TOKUDB_DBUG_ENTER("ha_tokudb::store_lock, lock_type=%d", lock_type); TOKUDB_DBUG_ENTER("ha_tokudb::store_lock, lock_type=%d", lock_type);
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) { if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) {
/* If we are not doing a LOCK TABLE, then allow multiple writers */ /* If we are not doing a LOCK TABLE, then allow multiple writers */
if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE_LOW_PRIORITY) && !thd->in_lock_tables) { if ((lock_type >= TL_WRITE_CONCURRENT_INSERT && lock_type <= TL_WRITE) && !thd->in_lock_tables) {
lock_type = TL_WRITE_ALLOW_WRITE; lock_type = TL_WRITE_ALLOW_WRITE;
} }
lock.type = lock_type; lock.type = lock_type;
......
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