[Gs-commits] Grayskull Repository branch, master, updated. git-migration-303-g281aa78
A ref change was pushed to the repository containing the project "Grayskull Repository". The branch, master has been updated via 281aa78117f68ba1bc46ea6213767e56839a05cb (commit) via 47fff9f0f804d326028e856e447c5d43b6df2323 (commit) via f0af59bef14edfc76999ef6ae50e26ab9629b8be (commit) from 14c57e23348aff2afda7709a05298029bb724ab4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 281aa78117f68ba1bc46ea6213767e56839a05cb Author: Phil Carns <[email protected]> Date: Wed Dec 16 16:09:25 2009 -0500 whitespace fixes commit 47fff9f0f804d326028e856e447c5d43b6df2323 Author: Phil Carns <[email protected]> Date: Wed Dec 16 16:06:01 2009 -0500 fix operation ordering in cosd benchmark commit f0af59bef14edfc76999ef6ae50e26ab9629b8be Author: Phil Carns <[email protected]> Date: Wed Dec 16 15:56:07 2009 -0500 preliminary db deadlock handling in cosd ----------------------------------------------------------------------- Summary of changes: .../gsl/resources/cosd-prototype/cosd-prototype.c | 106 ++++++++++++++++++-- .../cosd-prototype/test/cosd-bench-concurrent.gs | 15 ++-- 2 files changed, 103 insertions(+), 18 deletions(-) Diff of changes: diff --git a/code/src/gsl/resources/cosd-prototype/cosd-prototype.c b/code/src/gsl/resources/cosd-prototype/cosd-prototype.c index 0bfa578..dfda80e 100644 --- a/code/src/gsl/resources/cosd-prototype/cosd-prototype.c +++ b/code/src/gsl/resources/cosd-prototype/cosd-prototype.c @@ -467,7 +467,7 @@ int gs_cosd_init(enum progress_mode mode, const char* path) return(-1); } - /* have db do lock detection and reject txn with fewest locks */ + /* have db do deadlock detection and reject txn with fewest locks */ ret = envp->set_lk_detect(envp, DB_LOCK_MINWRITE); if(ret != 0) { @@ -771,6 +771,7 @@ static int write_op_worker(struct gs_op* op) COSD_INIT_DBT(key, c_op->u.write.oid); COSD_INIT_DBT(value, global_log_offset); +write_op_txn: /* read log offset from db */ ret = envp->txn_begin(envp, NULL, &txn, 0); if(ret != 0) @@ -783,6 +784,10 @@ static int write_op_worker(struct gs_op* op) ret = log_offset_dbp->get(log_offset_dbp, txn, &key, &value, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto write_op_txn; + /* TODO: error handling */ c_op->error_code = -1; return(1); @@ -791,6 +796,10 @@ static int write_op_worker(struct gs_op* op) ret = txn->commit(txn, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto write_op_txn; + /* TODO: error handling */ assert(0); } @@ -864,6 +873,7 @@ static int write_op_worker(struct gs_op* op) * * dumps all db information from cosd */ +/* TODO: audit for deadlocks */ static int dump_op_worker(struct gs_op* op) { struct cosd_op *c_op; @@ -983,6 +993,7 @@ static int dump_op_worker(struct gs_op* op) * * creates an object */ +/* TODO: audit for deadlocks */ static int create_op_worker(struct gs_op* op) { struct cosd_op *c_op; @@ -1229,6 +1240,7 @@ int gs_cosd_txn_open(uint64_t oid, uint64_t txn_number) * * retrieves the current version number of an object */ +/* TODO: audit for deadlocks */ static int get_version_op_worker(struct gs_op* op) { struct cosd_op *c_op; @@ -1371,6 +1383,19 @@ static int txn_close_op_worker(struct gs_op* op) gs_list_del(&txn_acc->hash_link); gs_mutex_unlock(&txn_mutex); +txn_close_op_retry: + on_disk_count = 0; + done = 0; + c_get_flag = DB_SET_RANGE; + /* clear up on disk list in case this is a retry */ + gs_list_for_each_safe(iterator, scratch, &on_disk_entries) + { + tmp_entry = gs_list_get_entry(iterator, struct + logical_map_entry, list_link); + gs_list_del(&tmp_entry->list_link); + free(tmp_entry); + } + /* do db stuff */ ret = envp->txn_begin(envp, NULL, &txn, 0); if(ret != 0) @@ -1385,6 +1410,9 @@ static int txn_close_op_worker(struct gs_op* op) ret = log_map_dbp->cursor(log_map_dbp, txn, &dbc_p, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; /* TODO: error handling */ assert(0); } @@ -1414,6 +1442,9 @@ static int txn_close_op_worker(struct gs_op* op) } if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; /* TODO: err handling */ assert(0); } @@ -1445,12 +1476,23 @@ static int txn_close_op_worker(struct gs_op* op) ret = dbc_p->c_del(dbc_p, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; /* TODO: err handling */ assert(0); } } } - dbc_p->c_close(dbc_p); + ret = dbc_p->c_close(dbc_p); + if(ret != 0) + { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; + /* TODO: error handling */ + assert(0); + } /* merge on disk and txn regions */ ret = merge_logical_map(&on_disk_entries, on_disk_count, @@ -1472,6 +1514,10 @@ static int txn_close_op_worker(struct gs_op* op) ret = log_map_dbp->put(log_map_dbp, txn, &key, &value, 0); if(ret != 0) { + txn->abort(txn); + free(free_ptr); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; /* TODO: err handling */ assert(0); } @@ -1485,6 +1531,10 @@ static int txn_close_op_worker(struct gs_op* op) ret = ver_dbp->get(ver_dbp, txn, &key, &value, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; + /* TODO: error handling */ assert(0); } @@ -1506,6 +1556,9 @@ static int txn_close_op_worker(struct gs_op* op) ret = missing_ver_dbp->put(missing_ver_dbp, txn, &mv_key, &mv_value, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; /* TODO: error handling */ assert(0); } @@ -1518,6 +1571,9 @@ static int txn_close_op_worker(struct gs_op* op) ret = ver_dbp->put(ver_dbp, txn, &key, &value, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; /* TODO: error handling */ assert(0); } @@ -1534,6 +1590,17 @@ static int txn_close_op_worker(struct gs_op* op) /* delete from db db */ ret = missing_ver_dbp->del(missing_ver_dbp, txn, &mv_key, 0); + if(ret == DB_LOCK_DEADLOCK) + { + txn->abort(txn); + goto txn_close_op_retry; + } + if(ret != 0 && ret != DB_NOTFOUND) + { + txn->abort(txn); + /* TODO: error handling */ + assert(0); + } } /* flush current log offset to db in the same txn */ @@ -1547,19 +1614,41 @@ static int txn_close_op_worker(struct gs_op* op) ret = log_offset_dbp->put(log_offset_dbp, txn, &key, &value, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; + /* TODO: error handling */ - c_op->error_code = -1; - return(1); + assert(0); } gs_mutex_unlock(&global_log_mutex); ret = txn->commit(txn, 0); if(ret != 0) { + txn->abort(txn); + if(ret == DB_LOCK_DEADLOCK) + goto txn_close_op_retry; + /* TODO: error handling */ assert(0); } + gs_list_for_each_safe(iterator, scratch, &on_disk_entries) + { + tmp_entry = gs_list_get_entry(iterator, struct + logical_map_entry, list_link); + gs_list_del(&tmp_entry->list_link); + free(tmp_entry); + } + gs_list_for_each_safe(iterator, scratch, &txn_acc->update_list) + { + tmp_entry = gs_list_get_entry(iterator, struct + logical_map_entry, list_link); + gs_list_del(&tmp_entry->list_link); + free(tmp_entry); + } + free(txn_acc); c_op->error_code = 0; return(1); @@ -1607,9 +1696,8 @@ gs_ret_t (* gs_cosd_txn_close)( /* merge_logical_map() * - * merges two logical maps into one map. The two input maps are destroyed - * by this function. The output map is allocated from scratch and can be - * freed via the free_ptr argument. + * merges two logical maps into one map. The output map is allocated from + * scratch and can be freed via the free_ptr argument. * * returns 0 on success, -errno on failure */ @@ -1650,10 +1738,8 @@ static int merge_logical_map(struct gs_list_link* list1_in, int { tmp_entry = gs_list_get_entry(iterator, struct logical_map_entry, list_link); - gs_list_del(&tmp_entry->list_link); list1_array[i] = *tmp_entry; i++; - free(tmp_entry); } assert(i==list1_count); i=0; @@ -1661,10 +1747,8 @@ static int merge_logical_map(struct gs_list_link* list1_in, int { tmp_entry = gs_list_get_entry(iterator, struct logical_map_entry, list_link); - gs_list_del(&tmp_entry->list_link); list2_array[i] = *tmp_entry; i++; - free(tmp_entry); } assert(i==list2_count); diff --git a/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs b/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs index 7a9de2a..3be7aed 100644 --- a/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs +++ b/code/src/gsl/resources/cosd-prototype/test/cosd-bench-concurrent.gs @@ -7,7 +7,7 @@ /* TODO: this needs to be in a header somewhere */ #ifndef llu -#if SIZEOF_LONG_INT == 4 +#if SIZEOF_LONG_INT == 4 # define llu(x) (x) # define lld(x) (x) # define SCANF_lld lld @@ -76,7 +76,7 @@ static __blocking int do_cosd_test(void) struct bench_op* tmp_op; int b_ret; /* TODO: make buffer size configurable, and check that - * nothing in workload desc is bigger than this + * nothing in workload desc is bigger than this */ int64_t buffer_size = 4*1024*1024; @@ -93,7 +93,6 @@ static __blocking int do_cosd_test(void) list_link); /* only writes for now */ assert(tmp_op->type == WRITE); - ret = gs_cosd_txn_open(1, b_version); if(ret != 0) { @@ -125,8 +124,10 @@ static __blocking int do_cosd_test(void) } } +#if 0 ret = gs_cosd_dump(); assert(ret == 0); +#endif return 0; } @@ -180,7 +181,7 @@ int main(int argc, char *argv[]) { if(line[0] == '#') continue; -#if SIZEOF_LONG_INT == 4 +#if SIZEOF_LONG_INT == 4 ret = sscanf(line, "%s %lld %lld", op_string, &offset, &size); #else ret = sscanf(line, "%s %ld %ld", op_string, &offset, &size); @@ -198,7 +199,7 @@ int main(int argc, char *argv[]) tmp_op->type = WRITE; tmp_op->offset = offset; tmp_op->size = size; - gs_list_add(&tmp_op->list_link, &op_list); + gs_list_add_tail(&tmp_op->list_link, &op_list); } fclose(desc); @@ -206,7 +207,7 @@ int main(int argc, char *argv[]) printf("# Initializing cosd in poll-driven mode.\n"); else printf("# Initializing cosd in thread-per-op mode.\n"); - + gs_cosd_init(mode, argv[3]); gs_context_create(&ctx, 1, "cosd"); @@ -218,7 +219,7 @@ int main(int argc, char *argv[]) pc++; gs_poll(ctx, 10000); } - + gs_cosd_finalize(); gs_context_destroy(ctx); return 0; hooks/post-receive -- Grayskull Repository
participants (1)
-
noreply@mcs.anl.gov