diff options
author | Keith Bostic <keith@wiredtiger.com> | 2015-06-06 13:23:21 -0400 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-06-29 13:52:26 +1000 |
commit | 2fc2b8bbe52b10e87ba898af13ea264018622bd9 (patch) | |
tree | 460c21717115887aa3fa6991efe9c9409d058abd | |
parent | a0c9c24db632dfed6df03f300375ea2a275898ef (diff) | |
download | mongo-2fc2b8bbe52b10e87ba898af13ea264018622bd9.tar.gz |
WT-1959 Add the "strict" configuration option to WT_SESSION.verify, default false, don't error if we leak blocks unless strict is configured.
(cherry picked from commit b3e3f19a08bbd8897dc0ba3f54b217292e35ea6b)
-rw-r--r-- | dist/api_data.py | 5 | ||||
-rw-r--r-- | src/block/block_mgr.c | 5 | ||||
-rw-r--r-- | src/block/block_vrfy.c | 19 | ||||
-rw-r--r-- | src/btree/bt_vrfy.c | 4 | ||||
-rw-r--r-- | src/config/config_def.c | 3 | ||||
-rw-r--r-- | src/include/block.h | 4 | ||||
-rw-r--r-- | src/include/extern.h | 2 | ||||
-rw-r--r-- | src/include/wiredtiger.in | 4 | ||||
-rw-r--r-- | test/format/wts.c | 2 |
9 files changed, 35 insertions, 13 deletions
diff --git a/dist/api_data.py b/dist/api_data.py index 8dbb2f2ae55..5ad422befb4 100644 --- a/dist/api_data.py +++ b/dist/api_data.py @@ -767,6 +767,11 @@ methods = { Config('dump_shape', 'false', r''' Display the shape of the tree after verification, using the application's message handler, intended for debugging''', + type='boolean'), + Config('strict', 'false', r''' + Treat any verification problem as an error; by default, verify will + warn, but not fail, in the case of errors that won't affect future + behavior (for example, a leaked block)''', type='boolean') ]), diff --git a/src/block/block_mgr.c b/src/block/block_mgr.c index 13e6ec73b32..558008ee7b0 100644 --- a/src/block/block_mgr.c +++ b/src/block/block_mgr.c @@ -302,9 +302,10 @@ __bm_salvage_end(WT_BM *bm, WT_SESSION_IMPL *session) * Start a block manager verify. */ static int -__bm_verify_start(WT_BM *bm, WT_SESSION_IMPL *session, WT_CKPT *ckptbase) +__bm_verify_start(WT_BM *bm, + WT_SESSION_IMPL *session, WT_CKPT *ckptbase, const char *cfg[]) { - return (__wt_block_verify_start(session, bm->block, ckptbase)); + return (__wt_block_verify_start(session, bm->block, ckptbase, cfg)); } /* diff --git a/src/block/block_vrfy.c b/src/block/block_vrfy.c index 1e341aff77a..29a9e4950b4 100644 --- a/src/block/block_vrfy.c +++ b/src/block/block_vrfy.c @@ -28,10 +28,11 @@ static int __verify_last_truncate(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *); * Start file verification. */ int -__wt_block_verify_start( - WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) +__wt_block_verify_start(WT_SESSION_IMPL *session, + WT_BLOCK *block, WT_CKPT *ckptbase, const char *cfg[]) { WT_CKPT *ckpt; + WT_CONFIG_ITEM cval; wt_off_t size; /* @@ -98,6 +99,10 @@ __wt_block_verify_start( */ WT_RET(__verify_last_avail(session, block, ckpt)); + /* Configuration: strict behavior on any error. */ + WT_RET(__wt_config_gets(session, cfg, "strict", &cval)); + block->verify_strict = cval.val ? 1 : 0; + block->verify = 1; return (0); } @@ -164,14 +169,18 @@ __wt_block_verify_end(WT_SESSION_IMPL *session, WT_BLOCK *block) /* Confirm we verified every file block. */ ret = __verify_filefrag_chk(session, block); + block->verify = 0; + block->verify_strict = 0; + block->verify_size = 0; + /* Discard the accumulated allocation list. */ __wt_block_extlist_free(session, &block->verify_alloc); /* Discard the fragment tracking lists. */ + block->frags = 0; __wt_free(session, block->fragfile); __wt_free(session, block->fragckpt); - block->verify = 0; return (ret); } @@ -434,7 +443,7 @@ __verify_filefrag_chk(WT_SESSION_IMPL *session, WT_BLOCK *block) return (0); __wt_errx(session, "file ranges never verified: %" PRIu64, count); - return (WT_ERROR); + return (block->verify_strict ? WT_ERROR : 0); } /* @@ -527,5 +536,5 @@ __verify_ckptfrag_chk(WT_SESSION_IMPL *session, WT_BLOCK *block) __wt_errx(session, "checkpoint ranges never verified: %" PRIu64, count); - return (WT_ERROR); + return (block->verify_strict ? WT_ERROR : 0); } diff --git a/src/btree/bt_vrfy.c b/src/btree/bt_vrfy.c index 45c2029f6ed..93d1ddad8c6 100644 --- a/src/btree/bt_vrfy.c +++ b/src/btree/bt_vrfy.c @@ -23,7 +23,7 @@ typedef struct { #define WT_VRFY_DUMP(vs) \ ((vs)->dump_address || \ (vs)->dump_blocks || (vs)->dump_pages || (vs)->dump_shape) - int dump_address; /* Debugging hooks */ + int dump_address; /* Configure: dump special */ int dump_blocks; int dump_pages; int dump_shape; @@ -176,7 +176,7 @@ __wt_verify(WT_SESSION_IMPL *session, const char *cfg[]) __wt_meta_ckptlist_get(session, btree->dhandle->name, &ckptbase)); /* Inform the underlying block manager we're verifying. */ - WT_ERR(bm->verify_start(bm, session, ckptbase)); + WT_ERR(bm->verify_start(bm, session, ckptbase, cfg)); bm_start = 1; /* Loop through the file's checkpoints, verifying each one. */ diff --git a/src/config/config_def.c b/src/config/config_def.c index 3ac09e5241e..d068c196771 100644 --- a/src/config/config_def.c +++ b/src/config/config_def.c @@ -337,6 +337,7 @@ static const WT_CONFIG_CHECK confchk_session_verify[] = { { "dump_offsets", "list", NULL, NULL, NULL }, { "dump_pages", "boolean", NULL, NULL, NULL }, { "dump_shape", "boolean", NULL, NULL, NULL }, + { "strict", "boolean", NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL } }; @@ -780,7 +781,7 @@ static const WT_CONFIG_ENTRY config_entries[] = { }, { "session.verify", "dump_address=0,dump_blocks=0,dump_offsets=,dump_pages=0," - "dump_shape=0", + "dump_shape=0,strict=0", confchk_session_verify }, { "table.meta", diff --git a/src/include/block.h b/src/include/block.h index 4ef1b9da4ec..fb8987efdb4 100644 --- a/src/include/block.h +++ b/src/include/block.h @@ -185,7 +185,8 @@ struct __wt_bm { int (*sync)(WT_BM *, WT_SESSION_IMPL *, int); int (*verify_addr)(WT_BM *, WT_SESSION_IMPL *, const uint8_t *, size_t); int (*verify_end)(WT_BM *, WT_SESSION_IMPL *); - int (*verify_start)(WT_BM *, WT_SESSION_IMPL *, WT_CKPT *); + int (*verify_start) + (WT_BM *, WT_SESSION_IMPL *, WT_CKPT *, const char *[]); int (*write) (WT_BM *, WT_SESSION_IMPL *, WT_ITEM *, uint8_t *, size_t *, int); int (*write_size)(WT_BM *, WT_SESSION_IMPL *, size_t *); @@ -246,6 +247,7 @@ struct __wt_block { /* Verification support */ int verify; /* If performing verification */ + int verify_strict; /* Fail hard on any error */ wt_off_t verify_size; /* Checkpoint's file size */ WT_EXTLIST verify_alloc; /* Verification allocation list */ uint64_t frags; /* Maximum frags in the file */ diff --git a/src/include/extern.h b/src/include/extern.h index 59e795893b5..147af2521f7 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -65,7 +65,7 @@ extern int __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size); extern int __wt_block_salvage_next(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, int *eofp); extern int __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, int valid); -extern int __wt_block_verify_start( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase); +extern int __wt_block_verify_start(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase, const char *cfg[]); extern int __wt_block_verify_end(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_verify_ckpt_load( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_BLOCK_CKPT *ci); extern int __wt_verify_ckpt_unload(WT_SESSION_IMPL *session, WT_BLOCK *block); diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in index 3e7f956d885..4804290acba 100644 --- a/src/include/wiredtiger.in +++ b/src/include/wiredtiger.in @@ -1337,6 +1337,10 @@ struct __wt_session { * @config{dump_shape, Display the shape of the tree after * verification\, using the application's message handler\, intended for * debugging., a boolean flag; default \c false.} + * @config{strict, Treat any verification problem as an error; by + * default\, verify will warn\, but not fail\, in the case of errors + * that won't affect future behavior (for example\, a leaked block)., a + * boolean flag; default \c false.} * @configend * @ebusy_errors */ diff --git a/test/format/wts.c b/test/format/wts.c index 4d65ce78e8c..aa8309d9eea 100644 --- a/test/format/wts.c +++ b/test/format/wts.c @@ -462,7 +462,7 @@ wts_verify(const char *tag) "=============== verify start ==============="); /* Session operations for LSM can return EBUSY. */ - ret = session->verify(session, g.uri, NULL); + ret = session->verify(session, g.uri, "strict"); if (ret != 0 && !(ret == EBUSY && DATASOURCE("lsm"))) die(ret, "session.verify: %s: %s", g.uri, tag); |