Commit f7ed08cb authored by Yoni Fogel's avatar Yoni Fogel

closes #5300 Fix bug where indexer would ignore return value from loader

git-svn-id: file:///svn/toku/tokudb@46164 c7de825b-a66e-492c-adef-691d508d4ae1
parent a2c7736c
...@@ -147,7 +147,7 @@ toku_indexer_unlock(DB_INDEXER* indexer) { ...@@ -147,7 +147,7 @@ toku_indexer_unlock(DB_INDEXER* indexer) {
// forward declare the test-only wrapper function for undo-do // forward declare the test-only wrapper function for undo-do
static int test_indexer_undo_do(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule); static int test_indexer_undo_do(DB_INDEXER *indexer, DB *hotdb, ULEHANDLE ule);
int int
toku_indexer_create_indexer(DB_ENV *env, toku_indexer_create_indexer(DB_ENV *env,
DB_TXN *txn, DB_TXN *txn,
DB_INDEXER **indexerp, DB_INDEXER **indexerp,
...@@ -155,18 +155,18 @@ toku_indexer_create_indexer(DB_ENV *env, ...@@ -155,18 +155,18 @@ toku_indexer_create_indexer(DB_ENV *env,
int N, int N,
DB *dest_dbs[/*N*/], DB *dest_dbs[/*N*/],
uint32_t db_flags[/*N*/] UU(), uint32_t db_flags[/*N*/] UU(),
uint32_t indexer_flags) uint32_t indexer_flags)
{ {
int rval = 0; int rval;
DB_INDEXER *indexer = 0; // set later when created DB_INDEXER *indexer = 0; // set later when created
*indexerp = NULL; *indexerp = NULL;
XCALLOC(indexer); // init to all zeroes (thus initializing the error_callback and poll_func) XCALLOC(indexer); // init to all zeroes (thus initializing the error_callback and poll_func)
if ( !indexer ) { rval = ENOMEM; goto create_exit; } if ( !indexer ) { rval = ENOMEM; goto create_exit; }
XCALLOC(indexer->i); // init to all zeroes (thus initializing all pointers to NULL) XCALLOC(indexer->i); // init to all zeroes (thus initializing all pointers to NULL)
if ( !indexer->i ) { rval = ENOMEM; goto create_exit; } if ( !indexer->i ) { rval = ENOMEM; goto create_exit; }
indexer->i->env = env; indexer->i->env = env;
indexer->i->txn = txn; indexer->i->txn = txn;
indexer->i->src_db = src_db; indexer->i->src_db = src_db;
...@@ -174,9 +174,9 @@ toku_indexer_create_indexer(DB_ENV *env, ...@@ -174,9 +174,9 @@ toku_indexer_create_indexer(DB_ENV *env,
indexer->i->dest_dbs = dest_dbs; indexer->i->dest_dbs = dest_dbs;
indexer->i->indexer_flags = indexer_flags; indexer->i->indexer_flags = indexer_flags;
indexer->i->loop_mod = 1000; // call poll_func every 1000 rows indexer->i->loop_mod = 1000; // call poll_func every 1000 rows
indexer->i->estimated_rows = 0; indexer->i->estimated_rows = 0;
indexer->i->undo_do = test_indexer_undo_do; // TEST export the undo do function indexer->i->undo_do = test_indexer_undo_do; // TEST export the undo do function
XCALLOC_N(N, indexer->i->fnums); XCALLOC_N(N, indexer->i->fnums);
if ( !indexer->i->fnums ) { rval = ENOMEM; goto create_exit; } if ( !indexer->i->fnums ) { rval = ENOMEM; goto create_exit; }
for(int i=0;i<indexer->i->N;i++) { for(int i=0;i<indexer->i->N;i++) {
...@@ -185,7 +185,7 @@ toku_indexer_create_indexer(DB_ENV *env, ...@@ -185,7 +185,7 @@ toku_indexer_create_indexer(DB_ENV *env,
indexer->i->filenums.num = N; indexer->i->filenums.num = N;
indexer->i->filenums.filenums = indexer->i->fnums; indexer->i->filenums.filenums = indexer->i->fnums;
indexer->i->test_only_flags = 0; // for test use only indexer->i->test_only_flags = 0; // for test use only
indexer->set_error_callback = toku_indexer_set_error_callback; indexer->set_error_callback = toku_indexer_set_error_callback;
indexer->set_poll_function = toku_indexer_set_poll_function; indexer->set_poll_function = toku_indexer_set_poll_function;
indexer->build = build_index; indexer->build = build_index;
...@@ -202,20 +202,20 @@ toku_indexer_create_indexer(DB_ENV *env, ...@@ -202,20 +202,20 @@ toku_indexer_create_indexer(DB_ENV *env,
// //
for (int i = 0; i < N; i++) { for (int i = 0; i < N; i++) {
DB_LOADER* loader = NULL; DB_LOADER* loader = NULL;
int r = env->create_loader(env, txn, &loader, dest_dbs[i], 1, &dest_dbs[i], NULL, NULL, DB_PRELOCKED_WRITE | LOADER_USE_PUTS); rval = env->create_loader(env, txn, &loader, dest_dbs[i], 1, &dest_dbs[i], NULL, NULL, DB_PRELOCKED_WRITE | LOADER_USE_PUTS);
if (r) { if (rval) {
goto create_exit; goto create_exit;
} }
r = loader->close(loader); rval = loader->close(loader);
if (r) { if (rval) {
goto create_exit; goto create_exit;
} }
} }
// create and initialize the leafentry cursor // create and initialize the leafentry cursor
rval = toku_le_cursor_create(&indexer->i->lec, db_struct_i(src_db)->ft_handle, db_txn_struct_i(txn)->tokutxn); rval = toku_le_cursor_create(&indexer->i->lec, db_struct_i(src_db)->ft_handle, db_txn_struct_i(txn)->tokutxn);
if ( !indexer->i->lec ) { goto create_exit; } if ( !indexer->i->lec ) { goto create_exit; }
// 2954: add recovery and rollback entries // 2954: add recovery and rollback entries
LSN hot_index_lsn; // not used (yet) LSN hot_index_lsn; // not used (yet)
TOKUTXN ttxn; TOKUTXN ttxn;
...@@ -225,7 +225,7 @@ toku_indexer_create_indexer(DB_ENV *env, ...@@ -225,7 +225,7 @@ toku_indexer_create_indexer(DB_ENV *env,
toku_multi_operation_client_lock(); toku_multi_operation_client_lock();
rval = toku_ft_hot_index(NULL, ttxn, filenums, 1, &hot_index_lsn); rval = toku_ft_hot_index(NULL, ttxn, filenums, 1, &hot_index_lsn);
toku_multi_operation_client_unlock(); toku_multi_operation_client_unlock();
if (rval == 0) { if (rval == 0) {
rval = associate_indexer_with_hot_dbs(indexer, dest_dbs, N); rval = associate_indexer_with_hot_dbs(indexer, dest_dbs, N);
} }
...@@ -233,14 +233,14 @@ create_exit: ...@@ -233,14 +233,14 @@ create_exit:
if ( rval == 0 ) { if ( rval == 0 ) {
indexer_undo_do_init(indexer); indexer_undo_do_init(indexer);
*indexerp = indexer; *indexerp = indexer;
(void) __sync_fetch_and_add(&STATUS_VALUE(INDEXER_CREATE), 1); (void) __sync_fetch_and_add(&STATUS_VALUE(INDEXER_CREATE), 1);
(void) __sync_fetch_and_add(&STATUS_VALUE(INDEXER_CURRENT), 1); (void) __sync_fetch_and_add(&STATUS_VALUE(INDEXER_CURRENT), 1);
if ( STATUS_VALUE(INDEXER_CURRENT) > STATUS_VALUE(INDEXER_MAX) ) if ( STATUS_VALUE(INDEXER_CURRENT) > STATUS_VALUE(INDEXER_MAX) )
STATUS_VALUE(INDEXER_MAX) = STATUS_VALUE(INDEXER_CURRENT); // NOT WORTH A LOCK TO MAKE THREADSAFE), may be inaccurate STATUS_VALUE(INDEXER_MAX) = STATUS_VALUE(INDEXER_CURRENT); // NOT WORTH A LOCK TO MAKE THREADSAFE), may be inaccurate
} else { } else {
(void) __sync_fetch_and_add(&STATUS_VALUE(INDEXER_CREATE_FAIL), 1); (void) __sync_fetch_and_add(&STATUS_VALUE(INDEXER_CREATE_FAIL), 1);
free_indexer(indexer); free_indexer(indexer);
...@@ -249,7 +249,7 @@ create_exit: ...@@ -249,7 +249,7 @@ create_exit:
return rval; return rval;
} }
int int
toku_indexer_set_poll_function(DB_INDEXER *indexer, toku_indexer_set_poll_function(DB_INDEXER *indexer,
int (*poll_func)(void *poll_extra, int (*poll_func)(void *poll_extra,
float progress), float progress),
......
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