From 245010c9c958166295b870703aa74605594773f9 Mon Sep 17 00:00:00 2001 From: Yoni Fogel Date: Tue, 16 Apr 2013 23:57:47 -0400 Subject: [PATCH] Addresses #1622 Merge changes on 1.1.3-1622/tokudb to main svn merge -r 10862:10863 ../../mysql.branches/1.1.3/tokudb/ svn merge -r 10879:10882 ../../mysql.branches/1.1.3-1622/tokudb/ git-svn-id: file:///svn/toku/tokudb@10890 c7de825b-a66e-492c-adef-691d508d4ae1 --- newbrt/brt-internal.h | 3 +++ newbrt/brt.c | 39 +++++++++++++++++++++++++++++++++++++++ newbrt/omt.c | 8 ++++---- src/ydb.c | 1 - 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/newbrt/brt-internal.h b/newbrt/brt-internal.h index 0238a0ad021..cbb66851582 100644 --- a/newbrt/brt-internal.h +++ b/newbrt/brt-internal.h @@ -17,6 +17,9 @@ typedef void *OMTVALUE; #include "block_table.h" #include "leaflock.h" +//Enable hacks to deal with missing straddle callback logic. +#define BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY + #ifndef BRT_FANOUT #define BRT_FANOUT 16 #endif diff --git a/newbrt/brt.c b/newbrt/brt.c index 8c77c5be549..ce33269e805 100644 --- a/newbrt/brt.c +++ b/newbrt/brt.c @@ -2353,9 +2353,18 @@ brt_merge_child (BRT t, BRTNODE node, int childnum_to_merge, BOOL *did_io, BOOL verify_local_fingerprint_nonleaf(node); return r; } +#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY +static int STRADDLE_HACK_disable_merges_and_splits = 0; +#endif static int brt_handle_maybe_reactive_child(BRT t, BRTNODE node, int childnum, enum reactivity re, BOOL *did_io, BOOL *did_react) { +#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY + if (STRADDLE_HACK_disable_merges_and_splits) { + *did_react = FALSE; + return 0; + } +#endif switch (re) { case RE_STABLE: *did_react = FALSE; @@ -2370,6 +2379,11 @@ brt_handle_maybe_reactive_child(BRT t, BRTNODE node, int childnum, enum reactivi static int brt_handle_maybe_reactive_child_at_root (BRT brt, CACHEKEY *rootp, BRTNODE *nodep, enum reactivity re, TOKULOGGER logger) { +#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY + if (STRADDLE_HACK_disable_merges_and_splits) { + return 0; + } +#endif BRTNODE node = *nodep; switch (re) { case RE_STABLE: @@ -4338,12 +4352,37 @@ static int brt_cursor_compare_heaviside(brt_search_t *search, DBT *x, DBT *y) { static const DBT __toku_dbt_fake; static const DBT* const toku_dbt_fake = &__toku_dbt_fake; +#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY +struct brt_cursor_straddle_search_struct { + BRT_GET_STRADDLE_CALLBACK_FUNCTION getf; + void *getf_v; + BRT_CURSOR cursor; + brt_search_t *search; +}; + +static int +straddle_hack_getf(ITEMLEN keylen, bytevec key, ITEMLEN vallen, bytevec val, + ITEMLEN next_keylen, bytevec next_key, ITEMLEN next_vallen, bytevec next_val, void* v) { + struct brt_cursor_straddle_search_struct *bcsss = v; + int old_hack_value = STRADDLE_HACK_disable_merges_and_splits; + STRADDLE_HACK_disable_merges_and_splits = 1; + int r = bcsss->getf(keylen, key, vallen, val, next_keylen, next_key, next_vallen, next_val, bcsss->getf_v); + STRADDLE_HACK_disable_merges_and_splits = old_hack_value; + return r; +} +#endif + /* search for the first kv pair that matches the search object */ static int brt_cursor_straddle_search(BRT_CURSOR cursor, brt_search_t *search, BRT_GET_STRADDLE_CALLBACK_FUNCTION getf, void *getf_v, TOKULOGGER logger) { brt_cursor_invalidate(cursor); +#ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY + struct brt_cursor_straddle_search_struct bcsss = {getf, getf_v, cursor, search}; + int r = toku_brt_search(cursor->brt, search, straddle_hack_getf, &bcsss, logger, cursor, &cursor->root_put_counter); +#else int r = toku_brt_search(cursor->brt, search, getf, getf_v, logger, cursor, &cursor->root_put_counter); +#endif return r; } diff --git a/newbrt/omt.c b/newbrt/omt.c index e94ced66794..4bba7e306a8 100644 --- a/newbrt/omt.c +++ b/newbrt/omt.c @@ -651,9 +651,9 @@ void toku_omt_cursor_set_index(OMTCURSOR c, u_int32_t index) { int toku_omt_cursor_next (OMTCURSOR c, OMTVALUE *v) { if (c->omt == NULL) return EINVAL; - c->index++; - int r = toku_omt_fetch(c->omt, c->index, v, NULL); - if (r!=0) toku_omt_cursor_invalidate(c); + int r = toku_omt_fetch(c->omt, c->index+1, v, NULL); + if (r==0) c->index++; + else toku_omt_cursor_invalidate(c); return r; } @@ -672,7 +672,7 @@ int toku_omt_cursor_prev (OMTCURSOR c, OMTVALUE *v) { int toku_omt_cursor_current (OMTCURSOR c, OMTVALUE *v) { if (c->omt == NULL) return EINVAL; int r = toku_omt_fetch(c->omt, c->index, v, NULL); - if (r!=0) toku_omt_cursor_invalidate(c); + assert(r==0); return r; } diff --git a/src/ydb.c b/src/ydb.c index 6b22dae76d1..522b2c909c2 100644 --- a/src/ydb.c +++ b/src/ydb.c @@ -2301,7 +2301,6 @@ static int c_getf_heaviside_callback(ITEMLEN found_keylen, bytevec found_keyvec, const DBT *right_key = toku_lt_infinity; const DBT *right_val = toku_lt_infinity; RANGE_LOCK_REQUEST_S request; -#define BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY 1 #ifdef BRT_LEVEL_STRADDLE_CALLBACK_LOGIC_NOT_READY //Have cursor (base->c) //Have txn (base->txn)