Commit 05ee9f03 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:2935], merge to main

git-svn-id: file:///svn/toku/tokudb@24885 c7de825b-a66e-492c-adef-691d508d4ae1
parent 72f04331
...@@ -494,6 +494,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v ...@@ -494,6 +494,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default"))); void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
void db_env_set_mvcc_garbage_collection_verification(u_int32_t) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -510,6 +510,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v ...@@ -510,6 +510,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default"))); void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
void db_env_set_mvcc_garbage_collection_verification(u_int32_t) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -516,6 +516,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v ...@@ -516,6 +516,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default"))); void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
void db_env_set_mvcc_garbage_collection_verification(u_int32_t) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -516,6 +516,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v ...@@ -516,6 +516,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default"))); void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
void db_env_set_mvcc_garbage_collection_verification(u_int32_t) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -520,6 +520,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v ...@@ -520,6 +520,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default"))); void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
void db_env_set_mvcc_garbage_collection_verification(u_int32_t) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -701,6 +701,7 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__ ...@@ -701,6 +701,7 @@ int main (int argc __attribute__((__unused__)), char *const argv[] __attribute__
printf("void db_env_set_recover_callback (void (*)(void*), void*) %s;\n", VISIBLE); printf("void db_env_set_recover_callback (void (*)(void*), void*) %s;\n", VISIBLE);
printf("void db_env_set_recover_callback2 (void (*)(void*), void*) %s;\n", VISIBLE); printf("void db_env_set_recover_callback2 (void (*)(void*), void*) %s;\n", VISIBLE);
printf("void db_env_set_loader_size_factor (uint32_t) %s;\n", VISIBLE); printf("void db_env_set_loader_size_factor (uint32_t) %s;\n", VISIBLE);
printf("void db_env_set_mvcc_garbage_collection_verification(u_int32_t) %s;\n", VISIBLE);
printf("#if defined(__cplusplus)\n}\n#endif\n"); printf("#if defined(__cplusplus)\n}\n#endif\n");
printf("#endif\n"); printf("#endif\n");
return 0; return 0;
......
...@@ -453,6 +453,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v ...@@ -453,6 +453,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default"))); void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
void db_env_set_mvcc_garbage_collection_verification(u_int32_t) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -453,6 +453,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v ...@@ -453,6 +453,7 @@ void db_env_set_checkpoint_callback2 (void (*)(void*), void*) __attribute__((__v
void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default"))); void db_env_set_recover_callback2 (void (*)(void*), void*) __attribute__((__visibility__("default")));
void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default"))); void db_env_set_loader_size_factor (uint32_t) __attribute__((__visibility__("default")));
void db_env_set_mvcc_garbage_collection_verification(u_int32_t) __attribute__((__visibility__("default")));
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif
......
...@@ -241,6 +241,8 @@ int toku_brt_strerror_r(int error, char *buf, size_t buflen); ...@@ -241,6 +241,8 @@ int toku_brt_strerror_r(int error, char *buf, size_t buflen);
// If error>=0 then the result is to do strerror_r(error, buf, buflen), that is fill buf with a descriptive error message. // If error>=0 then the result is to do strerror_r(error, buf, buflen), that is fill buf with a descriptive error message.
// If error<0 then return a TokuDB-specific error code. For unknown cases, we return -1 and set errno=EINVAL, even for cases that *should* be known. (Not all DB errors are known by this function which is a bug.) // If error<0 then return a TokuDB-specific error code. For unknown cases, we return -1 and set errno=EINVAL, even for cases that *should* be known. (Not all DB errors are known by this function which is a bug.)
extern BOOL garbage_collection_debug;
C_END C_END
#endif #endif
...@@ -9,9 +9,10 @@ ...@@ -9,9 +9,10 @@
#include "checkpoint.h" #include "checkpoint.h"
#include "ule.h" #include "ule.h"
#if GARBAGE_COLLECTION_DEBUG
BOOL garbage_collection_debug = FALSE;
static void verify_snapshot_system(TOKULOGGER logger); static void verify_snapshot_system(TOKULOGGER logger);
#endif
// accountability // accountability
static TXN_STATUS_S status = {.begin = 0, static TXN_STATUS_S status = {.begin = 0,
...@@ -127,9 +128,9 @@ int toku_txn_begin_with_xid ( ...@@ -127,9 +128,9 @@ int toku_txn_begin_with_xid (
) )
{ {
if (logger->is_panicked) return EINVAL; if (logger->is_panicked) return EINVAL;
#if GARBAGE_COLLECTION_DEBUG if (garbage_collection_debug) {
verify_snapshot_system(logger); verify_snapshot_system(logger);
#endif }
assert(logger->rollback_cachefile); assert(logger->rollback_cachefile);
TOKUTXN MALLOC(result); TOKUTXN MALLOC(result);
if (result==0) if (result==0)
...@@ -222,9 +223,9 @@ int toku_txn_begin_with_xid ( ...@@ -222,9 +223,9 @@ int toku_txn_begin_with_xid (
toku_list_init(&result->checkpoint_before_commit); toku_list_init(&result->checkpoint_before_commit);
*tokutxn = result; *tokutxn = result;
status.begin++; status.begin++;
#if GARBAGE_COLLECTION_DEBUG if (garbage_collection_debug) {
verify_snapshot_system(logger); verify_snapshot_system(logger);
#endif }
return 0; return 0;
died: died:
...@@ -315,9 +316,9 @@ local_checkpoints_and_log_xcommit(void *thunk) { ...@@ -315,9 +316,9 @@ local_checkpoints_and_log_xcommit(void *thunk) {
int toku_txn_commit_with_lsn(TOKUTXN txn, int nosync, YIELDF yield, void *yieldv, LSN oplsn, int toku_txn_commit_with_lsn(TOKUTXN txn, int nosync, YIELDF yield, void *yieldv, LSN oplsn,
TXN_PROGRESS_POLL_FUNCTION poll, void *poll_extra) { TXN_PROGRESS_POLL_FUNCTION poll, void *poll_extra) {
#if GARBAGE_COLLECTION_DEBUG if (garbage_collection_debug) {
verify_snapshot_system(txn->logger); verify_snapshot_system(txn->logger);
#endif }
int r; int r;
// panic handled in log_commit // panic handled in log_commit
...@@ -351,9 +352,9 @@ int toku_txn_abort_txn(TOKUTXN txn, YIELDF yield, void *yieldv, ...@@ -351,9 +352,9 @@ int toku_txn_abort_txn(TOKUTXN txn, YIELDF yield, void *yieldv,
int toku_txn_abort_with_lsn(TOKUTXN txn, YIELDF yield, void *yieldv, LSN oplsn, int toku_txn_abort_with_lsn(TOKUTXN txn, YIELDF yield, void *yieldv, LSN oplsn,
TXN_PROGRESS_POLL_FUNCTION poll, void *poll_extra) { TXN_PROGRESS_POLL_FUNCTION poll, void *poll_extra) {
#if GARBAGE_COLLECTION_DEBUG if (garbage_collection_debug) {
verify_snapshot_system(txn->logger); verify_snapshot_system(txn->logger);
#endif }
//printf("%s:%d aborting\n", __FILE__, __LINE__); //printf("%s:%d aborting\n", __FILE__, __LINE__);
// Must undo everything. Must undo it all in reverse order. // Must undo everything. Must undo it all in reverse order.
// Build the reverse list // Build the reverse list
...@@ -371,14 +372,11 @@ int toku_txn_abort_with_lsn(TOKUTXN txn, YIELDF yield, void *yieldv, LSN oplsn, ...@@ -371,14 +372,11 @@ int toku_txn_abort_with_lsn(TOKUTXN txn, YIELDF yield, void *yieldv, LSN oplsn,
} }
void toku_txn_close_txn(TOKUTXN txn) { void toku_txn_close_txn(TOKUTXN txn) {
#if GARBAGE_COLLECTION_DEBUG
TOKULOGGER logger = txn->logger; TOKULOGGER logger = txn->logger;
#endif
toku_rollback_txn_close(txn); toku_rollback_txn_close(txn);
#if GARBAGE_COLLECTION_DEBUG if (garbage_collection_debug) {
verify_snapshot_system(logger); verify_snapshot_system(logger);
#endif }
status.close++; status.close++;
return; return;
} }
...@@ -442,7 +440,6 @@ BOOL toku_is_txn_in_live_root_txn_list(TOKUTXN txn, TXNID xid) { ...@@ -442,7 +440,6 @@ BOOL toku_is_txn_in_live_root_txn_list(TOKUTXN txn, TXNID xid) {
return retval; return retval;
} }
#if GARBAGE_COLLECTION_DEBUG
static void static void
verify_snapshot_system(TOKULOGGER logger) { verify_snapshot_system(TOKULOGGER logger) {
int num_snapshot_txnids = toku_omt_size(logger->snapshot_txnids); int num_snapshot_txnids = toku_omt_size(logger->snapshot_txnids);
...@@ -551,5 +548,4 @@ verify_snapshot_system(TOKULOGGER logger) { ...@@ -551,5 +548,4 @@ verify_snapshot_system(TOKULOGGER logger) {
} }
} }
} }
#endif
...@@ -202,14 +202,13 @@ garbage_collection(ULE ule, OMT snapshot_xids, OMT live_list_reverse) { ...@@ -202,14 +202,13 @@ garbage_collection(ULE ule, OMT snapshot_xids, OMT live_list_reverse) {
break; break;
} }
} }
#if GARBAGE_COLLECTION_DEBUG if (garbage_collection_debug)
{ {
u_int32_t idx; u_int32_t idx;
OMTVALUE txnagain; OMTVALUE txnagain;
int r = toku_omt_find_zero(snapshot_xids, toku_find_xid_by_xid, &tl1, &txnagain, &idx, NULL); int r = toku_omt_find_zero(snapshot_xids, toku_find_xid_by_xid, &tl1, &txnagain, &idx, NULL);
invariant(r==0); //make sure that the txn you are claiming is live is actually live invariant(r==0); //make sure that the txn you are claiming is live is actually live
} }
#endif
// //
// tl1 should now be set // tl1 should now be set
// //
......
...@@ -18,7 +18,6 @@ extern "C" { ...@@ -18,7 +18,6 @@ extern "C" {
//1 does much slower debugging //1 does much slower debugging
#define ULE_DEBUG 0 #define ULE_DEBUG 0
#define GARBAGE_COLLECTION_DEBUG 0
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
// Following data structures are the unpacked format of a leafentry. // Following data structures are the unpacked format of a leafentry.
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
db_env_set_recover_callback; db_env_set_recover_callback;
db_env_set_recover_callback2; db_env_set_recover_callback2;
db_env_set_loader_size_factor; db_env_set_loader_size_factor;
db_env_set_mvcc_garbage_collection_verification;
toku_os_get_max_rss; toku_os_get_max_rss;
......
...@@ -2,11 +2,18 @@ ...@@ -2,11 +2,18 @@
// In particular, check to see what happens if a subtransaction has different isolation level from its parent. // In particular, check to see what happens if a subtransaction has different isolation level from its parent.
#include "test.h" #include "test.h"
const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_PRIVATE; const int envflags = DB_INIT_MPOOL|DB_CREATE|DB_THREAD |DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_PRIVATE;
int test_main (int argc, char * const argv[]) { int test_main (int argc, char * const argv[]) {
parse_args(argc, argv); parse_args(argc, argv);
int useseed;
{
struct timeval tv;
gettimeofday(&tv, 0);
useseed = tv.tv_sec+tv.tv_usec*997; // magic: 997 is a prime, and a million (microseconds/second) times 997 is still 32 bits.
}
int r; int r;
r = system("rm -rf " ENVDIR); r = system("rm -rf " ENVDIR);
CKERR(r); CKERR(r);
...@@ -17,20 +24,26 @@ int test_main (int argc, char * const argv[]) { ...@@ -17,20 +24,26 @@ int test_main (int argc, char * const argv[]) {
env->set_errfile(env, stderr); env->set_errfile(env, stderr);
r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO); r = env->open(env, ENVDIR, envflags, S_IRWXU+S_IRWXG+S_IRWXO);
CKERR(r); CKERR(r);
db_env_set_mvcc_garbage_collection_verification(1);
int max_txns = 2000; int max_txns = 400;
int num_runs = 10000; int num_runs = 2000;
DB_TXN* txns[max_txns]; DB_TXN* txns[max_txns];
memset(txns, 0, sizeof(txns)); memset(txns, 0, sizeof(txns));
int num_txns = 0; int num_txns = 0;
int i; int i;
if (verbose) printf("seed=%d\n", useseed);
srandom(useseed);
for (i = 0; i < num_runs; i++) { for (i = 0; i < num_runs; i++) {
int rand_num = random()%max_txns; int rand_num = random()%max_txns;
//if (i%50 == 0) { /*
// printf("num_txns %d\n", num_txns); if (i%50 == 0) {
// printf("iteration %d\n", i); printf("rand_num %d\n", rand_num);
//} printf("num_txns %d\n", num_txns);
printf("iteration %d\n", i);
}
*/
if (rand_num >= num_txns) { if (rand_num >= num_txns) {
// add a txn // add a txn
assert(txns[num_txns] == NULL); assert(txns[num_txns] == NULL);
......
...@@ -4992,6 +4992,9 @@ void db_env_set_loader_size_factor (uint32_t factor) { ...@@ -4992,6 +4992,9 @@ void db_env_set_loader_size_factor (uint32_t factor) {
} }
void db_env_set_mvcc_garbage_collection_verification(u_int32_t verification_mode) {
garbage_collection_debug = (verification_mode != 0);
}
......
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