Skip to content

Commit

Permalink
WT-2287: Add support for a WT_SESSION.rebalance method that rebuilds the
Browse files Browse the repository at this point in the history
underlying btree, correcting any imbalance.
  • Loading branch information
keithbostic committed Dec 17, 2015
1 parent 1dc7358 commit 1df86bf
Show file tree
Hide file tree
Showing 30 changed files with 807 additions and 71 deletions.
1 change: 1 addition & 0 deletions SConstruct
Expand Up @@ -290,6 +290,7 @@ wtbin = env.Program("wt", [
"src/utilities/util_misc.c",
"src/utilities/util_printlog.c",
"src/utilities/util_read.c",
"src/utilities/util_rebalance.c",
"src/utilities/util_rename.c",
"src/utilities/util_salvage.c",
"src/utilities/util_stat.c",
Expand Down
1 change: 1 addition & 0 deletions build_posix/Make.base
Expand Up @@ -31,6 +31,7 @@ wt_SOURCES =\
src/utilities/util_misc.c \
src/utilities/util_printlog.c \
src/utilities/util_read.c \
src/utilities/util_rebalance.c \
src/utilities/util_rename.c \
src/utilities/util_salvage.c \
src/utilities/util_stat.c \
Expand Down
1 change: 1 addition & 0 deletions build_win/filelist.win
Expand Up @@ -31,6 +31,7 @@ src/btree/bt_misc.c
src/btree/bt_ovfl.c
src/btree/bt_page.c
src/btree/bt_read.c
src/btree/bt_rebalance.c
src/btree/bt_ret.c
src/btree/bt_slvg.c
src/btree/bt_split.c
Expand Down
2 changes: 2 additions & 0 deletions dist/api_data.py
Expand Up @@ -564,6 +564,7 @@ def __cmp__(self, other):
'mutex',
'overflow',
'read',
'rebalance',
'reconcile',
'recovery',
'salvage',
Expand Down Expand Up @@ -892,6 +893,7 @@ def __cmp__(self, other):
type='list'),
]),

'WT_SESSION.rebalance' : Method([]),
'WT_SESSION.rename' : Method([]),
'WT_SESSION.reset' : Method([]),
'WT_SESSION.salvage' : Method([
Expand Down
1 change: 1 addition & 0 deletions dist/filelist
Expand Up @@ -31,6 +31,7 @@ src/btree/bt_misc.c
src/btree/bt_ovfl.c
src/btree/bt_page.c
src/btree/bt_read.c
src/btree/bt_rebalance.c
src/btree/bt_ret.c
src/btree/bt_slvg.c
src/btree/bt_split.c
Expand Down
1 change: 1 addition & 0 deletions dist/flags.py
Expand Up @@ -70,6 +70,7 @@
'VERB_MUTEX',
'VERB_OVERFLOW',
'VERB_READ',
'VERB_REBALANCE',
'VERB_RECONCILE',
'VERB_RECOVERY',
'VERB_SALVAGE',
Expand Down
2 changes: 2 additions & 0 deletions dist/s_string.ok
Expand Up @@ -254,6 +254,7 @@ RNG
RPC
RUNDIR
Radu
Rebalance
RedHat
Redistributions
Resize
Expand Down Expand Up @@ -857,6 +858,7 @@ readlock
readonly
readunlock
realloc
rebalance
rebalancing
recno
recnos
Expand Down
4 changes: 4 additions & 0 deletions examples/c/ex_all.c
Expand Up @@ -673,6 +673,10 @@ session_ops(WT_SESSION *session)
ret = session->compact(session, "table:mytable", NULL);
/*! [Compact a table] */

/*! [Rebalance a table] */
ret = session->rebalance(session, "table:old", NULL);
/*! [Rebalance a table] */

/*! [Rename a table] */
ret = session->rename(session, "table:old", "table:new", NULL);
/*! [Rename a table] */
Expand Down
1 change: 1 addition & 0 deletions lang/java/java_doc.i
Expand Up @@ -36,6 +36,7 @@ COPYDOC(__wt_session, WT_SESSION, drop)
COPYDOC(__wt_session, WT_SESSION, join)
COPYDOC(__wt_session, WT_SESSION, log_flush)
COPYDOC(__wt_session, WT_SESSION, log_printf)
COPYDOC(__wt_session, WT_SESSION, rebalance)
COPYDOC(__wt_session, WT_SESSION, rename)
COPYDOC(__wt_session, WT_SESSION, reset)
COPYDOC(__wt_session, WT_SESSION, salvage)
Expand Down
25 changes: 17 additions & 8 deletions src/btree/bt_handle.c
Expand Up @@ -105,14 +105,23 @@ __wt_btree_open(WT_SESSION_IMPL *session, const char *op_cfg[])
WT_ERR(__wt_btree_tree_open(
session, root_addr, root_addr_size));

/* Warm the cache, if possible. */
WT_WITH_PAGE_INDEX(session,
ret = __btree_preload(session));
WT_ERR(ret);

/* Get the last record number in a column-store file. */
if (btree->type != BTREE_ROW)
WT_ERR(__btree_get_last_recno(session));
/*
* Rebalance uses the cache, but only wants the root
* page, nothing else.
*/
if (!F_ISSET(btree, WT_BTREE_REBALANCE)) {
/* Warm the cache, if possible. */
WT_WITH_PAGE_INDEX(session,
ret = __btree_preload(session));
WT_ERR(ret);

/*
* Get the last record number in a column-store
* file.
*/
if (btree->type != BTREE_ROW)
WT_ERR(__btree_get_last_recno(session));
}
}
}

Expand Down

0 comments on commit 1df86bf

Please sign in to comment.