Skip to content

Commit

Permalink
WT-1959 Add the "strict" configuration option to WT_SESSION.verify, d…
Browse files Browse the repository at this point in the history
…efault false, don't error if we leak blocks unless strict is configured.

(cherry picked from commit b3e3f19)
  • Loading branch information
keithbostic authored and michaelcahill committed Jun 29, 2015
1 parent a0c9c24 commit 2fc2b8b
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
5 changes: 5 additions & 0 deletions dist/api_data.py
Expand Up @@ -767,6 +767,11 @@ def __cmp__(self, other):
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')
]),

Expand Down
5 changes: 3 additions & 2 deletions src/block/block_mgr.c
Expand Up @@ -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));
}

/*
Expand Down
19 changes: 14 additions & 5 deletions src/block/block_vrfy.c
Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -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);
}
4 changes: 2 additions & 2 deletions src/btree/bt_vrfy.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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. */
Expand Down
3 changes: 2 additions & 1 deletion src/config/config_def.c
Expand Up @@ -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 }
};

Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/include/block.h
Expand Up @@ -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 *);
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/include/extern.h
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/include/wiredtiger.in
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion test/format/wts.c
Expand Up @@ -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);

Expand Down

0 comments on commit 2fc2b8b

Please sign in to comment.