diff options
author | Luke Chen <luke.chen@mongodb.com> | 2020-05-25 16:00:29 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-25 06:15:55 +0000 |
commit | cd9c3303210860a33abf884350bd72856f0b85ce (patch) | |
tree | 261e5a7cde65b5e0d32278a5528d83f61dcee85d /src/third_party/wiredtiger/test/format/salvage.c | |
parent | 79e20534382a795e1b73ff276599cc91e49fc47e (diff) | |
download | mongo-cd9c3303210860a33abf884350bd72856f0b85ce.tar.gz |
Import wiredtiger: 0ec94ad7e360d93cb91f558d7efc03c644b1a9f8 from branch mongodb-4.4
ref: 5a3c70d7e4..0ec94ad7e3
for: 4.4.0-rc7
WT-6199 Fix PPC test variables in evergreen.yml
WT-6219 Fix application threads history store visibility during eviction
WT-6220 Add statistics tracking when times are written to disk
WT-6251 Fix splits to reduce the size of index files
WT-6260 Disable post salvage verify in format
WT-6266 Metadata verify of the HS file can fail if underlying objects are corrupted
WT-6278 Return from resolve prepared op when we have already resolved the operations
WT-6284 History store isn't visible to wt dump
WT-6287 Remove WT_TXN_HAS_TS_READ flag
Diffstat (limited to 'src/third_party/wiredtiger/test/format/salvage.c')
-rw-r--r-- | src/third_party/wiredtiger/test/format/salvage.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/third_party/wiredtiger/test/format/salvage.c b/src/third_party/wiredtiger/test/format/salvage.c index b9aca837215..8d1a2e7ed0f 100644 --- a/src/third_party/wiredtiger/test/format/salvage.c +++ b/src/third_party/wiredtiger/test/format/salvage.c @@ -58,7 +58,8 @@ corrupt(void) wt_off_t offset; size_t len, nw; int fd, ret; - char buf[8 * 1024], copycmd[2 * 1024]; + char copycmd[2 * 1024], path[1024]; + const char *smash; /* * If it's a single Btree file (not LSM), open the file, and corrupt roughly 2% of the file at a @@ -67,14 +68,14 @@ corrupt(void) * It's a little tricky: if the data source is a file, we're looking for "wt", if the data * source is a table, we're looking for "wt.wt". */ - testutil_check(__wt_snprintf(buf, sizeof(buf), "%s/%s", g.home, WT_NAME)); - if ((fd = open(buf, O_RDWR)) != -1) { + testutil_check(__wt_snprintf(path, sizeof(path), "%s/%s", g.home, WT_NAME)); + if ((fd = open(path, O_RDWR)) != -1) { testutil_check(__wt_snprintf(copycmd, sizeof(copycmd), "cp %s/%s %s/SALVAGE.copy/%s.corrupted", g.home, WT_NAME, g.home, WT_NAME)); goto found; } - testutil_check(__wt_snprintf(buf, sizeof(buf), "%s/%s.wt", g.home, WT_NAME)); - if ((fd = open(buf, O_RDWR)) != -1) { + testutil_check(__wt_snprintf(path, sizeof(path), "%s/%s.wt", g.home, WT_NAME)); + if ((fd = open(path, O_RDWR)) != -1) { testutil_check(__wt_snprintf(copycmd, sizeof(copycmd), "cp %s/%s.wt %s/SALVAGE.copy/%s.wt.corrupted", g.home, WT_NAME, g.home, WT_NAME)); goto found; @@ -87,9 +88,9 @@ found: offset = mmrand(NULL, 0, (u_int)sb.st_size); len = (size_t)(20 + (sb.st_size / 100) * 2); - testutil_check(__wt_snprintf(buf, sizeof(buf), "%s/SALVAGE.corrupt", g.home)); - if ((fp = fopen(buf, "w")) == NULL) - testutil_die(errno, "salvage-corrupt: open: %s", buf); + testutil_check(__wt_snprintf(path, sizeof(path), "%s/SALVAGE.corrupt", g.home)); + if ((fp = fopen(path, "w")) == NULL) + testutil_die(errno, "salvage-corrupt: open: %s", path); (void)fprintf(fp, "salvage-corrupt: offset %" PRIuMAX ", length %" WT_SIZET_FMT "\n", (uintmax_t)offset, len); fclose_and_clear(&fp); @@ -97,10 +98,10 @@ found: if (lseek(fd, offset, SEEK_SET) == -1) testutil_die(errno, "salvage-corrupt: lseek"); - memset(buf, 'z', sizeof(buf)); + smash = "!!! memory corrupted by format to test salvage "; for (; len > 0; len -= nw) { - nw = (size_t)(len > sizeof(buf) ? sizeof(buf) : len); - if (write(fd, buf, nw) == -1) + nw = (size_t)(len > strlen(smash) ? strlen(smash) : len); + if (write(fd, smash, nw) == -1) testutil_die(errno, "salvage-corrupt: write"); } @@ -150,16 +151,17 @@ wts_salvage(void) free(cmd); /* Salvage, then verify. */ - wts_open(g.home, true, &g.wts_conn); + wts_open(g.home, true, &g.wts_conn, true); salvage(); +#if 0 wts_verify("post-salvage verify"); +#endif wts_close(); /* Corrupt the file randomly, salvage, then verify. */ if (corrupt()) { - wts_open(g.home, true, &g.wts_conn); + wts_open(g.home, true, &g.wts_conn, false); salvage(); - wts_verify("post-corrupt-salvage verify"); wts_close(); } } |