Skip to content

Commit 9cc883a

Browse files
lukechEvergreen Agent
authored andcommitted
Import wiredtiger: e1b78d648cddcd854c435b5c04848993de6e349a from branch mongodb-master
ref: 37670c7d34..e1b78d648c for: 7.3.0-rc0 WT-11987 Modify the metadata base tracking to detect corruption better.
1 parent c732107 commit 9cc883a

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

src/third_party/wiredtiger/import.data

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"vendor": "wiredtiger",
33
"github": "wiredtiger/wiredtiger.git",
44
"branch": "mongodb-master",
5-
"commit": "37670c7d34260232ea2fb0088229402381454459"
5+
"commit": "e1b78d648cddcd854c435b5c04848993de6e349a"
66
}

src/third_party/wiredtiger/src/conn/conn_dhandle.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ __conn_dhandle_config_set(WT_SESSION_IMPL *session)
117117
}
118118
dhandle->cfg[1] = metaconf;
119119
dhandle->meta_base = base;
120-
dhandle->meta_base_length = base == NULL ? 0 : strlen(base);
121-
#ifdef HAVE_DIAGNOSTIC
122120
/* Save the original metadata value for further check to avoid writing corrupted data. */
123-
if (base == NULL)
124-
dhandle->orig_meta_base = NULL;
125-
else
121+
if (base != NULL) {
122+
dhandle->meta_hash = __wt_hash_city64(base, strlen(base));
123+
__wt_epoch(session, &dhandle->base_upd);
126124
WT_ERR(__wt_strdup(session, base, &dhandle->orig_meta_base));
127-
#endif
125+
dhandle->orig_meta_hash = dhandle->meta_hash;
126+
dhandle->orig_upd = dhandle->base_upd;
127+
}
128128
return (0);
129129

130130
err:

src/third_party/wiredtiger/src/include/dhandle.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,17 @@ struct __wt_data_handle {
7979
TAILQ_ENTRY(__wt_data_handle) q;
8080
TAILQ_ENTRY(__wt_data_handle) hashq;
8181

82-
const char *name; /* Object name as a URI */
83-
uint64_t name_hash; /* Hash of name */
84-
const char *checkpoint; /* Checkpoint name (or NULL) */
85-
int64_t checkpoint_order; /* Checkpoint order number, when applicable */
86-
const char **cfg; /* Configuration information */
87-
const char *meta_base; /* Base metadata configuration */
88-
size_t meta_base_length; /* Base metadata length */
89-
#ifdef HAVE_DIAGNOSTIC
82+
const char *name; /* Object name as a URI */
83+
uint64_t name_hash; /* Hash of name */
84+
const char *checkpoint; /* Checkpoint name (or NULL) */
85+
int64_t checkpoint_order; /* Checkpoint order number, when applicable */
86+
const char **cfg; /* Configuration information */
87+
const char *meta_base; /* Base metadata configuration */
88+
uint64_t meta_hash; /* Base metadata hash */
89+
struct timespec base_upd; /* Time of last metadata update with meta base */
9090
const char *orig_meta_base; /* Copy of the base metadata configuration */
91-
#endif
91+
uint64_t orig_meta_hash; /* Copy of base metadata hash */
92+
struct timespec orig_upd; /* Time of original setup of meta base */
9293
/*
9394
* Sessions holding a connection's data handle and queued tiered storage work units will hold
9495
* references; sessions using a connection's data handle will have a non-zero in-use count.

src/third_party/wiredtiger/src/meta/meta_ckpt.c

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,11 @@ __wt_meta_checkpoint_clear(WT_SESSION_IMPL *session, const char *fname)
272272
static int
273273
__ckpt_set(WT_SESSION_IMPL *session, const char *fname, const char *v, bool use_base)
274274
{
275+
struct timespec ts;
275276
WT_DATA_HANDLE *dhandle;
276277
WT_DECL_ITEM(tmp);
277278
WT_DECL_RET;
278-
size_t meta_base_length;
279+
uint64_t base_hash;
279280
char *config, *newcfg;
280281
const char *cfg[3], *meta_base, *str;
281282

@@ -294,27 +295,23 @@ __ckpt_set(WT_SESSION_IMPL *session, const char *fname, const char *v, bool use_
294295

295296
/* Check the metadata is not corrupted. */
296297
meta_base = dhandle->meta_base;
297-
meta_base_length = strlen(meta_base);
298-
if (dhandle->meta_base_length != meta_base_length)
298+
base_hash = __wt_hash_city64(meta_base, strlen(meta_base));
299+
__wt_epoch(session, &ts);
300+
if (dhandle->meta_hash != base_hash)
299301
WT_ERR_PANIC(session, WT_PANIC,
300-
"Corrupted metadata. The original metadata length was %lu while the new one is %lu.",
301-
dhandle->meta_base_length, meta_base_length);
302-
#ifdef HAVE_DIAGNOSTIC
303-
if (!WT_STREQ(dhandle->orig_meta_base, meta_base))
304-
WT_ERR_PANIC(session, WT_PANIC,
305-
"Corrupted metadata. The original metadata length was %lu while the new one is %lu. "
306-
"The original metadata inserted was %s and the current "
302+
"Corrupted metadata. The original metadata inserted was %s and the current "
307303
"metadata is now %s.",
308-
dhandle->meta_base_length, meta_base_length, dhandle->orig_meta_base, meta_base);
309-
#endif
304+
dhandle->orig_meta_base, meta_base);
305+
else
306+
/*
307+
* Only if the hash matches, update the time structure to know when we last had a
308+
* matching hash. If there is a problem with the metadata string then we have bounded
309+
* the time from what is in the dhandle to the local time structure we have.
310+
*/
311+
dhandle->base_upd = ts;
310312

311313
/* Concatenate the metadata base string with the checkpoint string. */
312314
WT_ERR(__wt_buf_fmt(session, tmp, "%s,%s", meta_base, str));
313-
/*
314-
* Check the new metadata length is at least as long as the original metadata string with
315-
* the checkpoint base stripped out.
316-
*/
317-
WT_ASSERT(session, tmp->size >= dhandle->meta_base_length);
318315
WT_ERR(__wt_metadata_update(session, fname, tmp->mem));
319316
} else {
320317
/* Retrieve the metadata for this file. */

0 commit comments

Comments
 (0)