Skip to content

Commit 41b289f

Browse files
quchenhaoEvergreen Agent
authored andcommitted
Import wiredtiger: 3a63ddcbed28c5f40ef026c55b85e34042a9715d from branch mongodb-3.6
ref: 723a4c1329..3a63ddcbed for: 3.6.19 WT-5119 Birthmark records can be read as normal updates if reads race with checkpoints WT-5150 LAS sweep is not removing the entries that are no longer required WT-5196 Data mismatch failures with test/checkpoint after enabling LAS sweep WT-5376 WT_UPDATE.type field can race with visibility checks when returning key/value pairs WT-5587 Limit how many checkpoints are dropped by a subsequent checkpoint
1 parent f0253e7 commit 41b289f

File tree

5 files changed

+61
-47
lines changed

5 files changed

+61
-47
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-3.6",
5-
"commit": "723a4c13292b0bc7e27be411db4d006a0b865bd8"
5+
"commit": "3a63ddcbed28c5f40ef026c55b85e34042a9715d"
66
}

src/third_party/wiredtiger/src/cache/cache_las.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,11 +1035,8 @@ __las_sweep_init(WT_SESSION_IMPL *session)
10351035
* If no files have been dropped and the lookaside file is empty,
10361036
* there's nothing to do.
10371037
*/
1038-
if (cache->las_dropped_next == 0) {
1039-
if (__wt_las_empty(session))
1040-
ret = WT_NOTFOUND;
1041-
goto err;
1042-
}
1038+
if (cache->las_dropped_next == 0 && __wt_las_empty(session))
1039+
WT_ERR(WT_NOTFOUND);
10431040

10441041
/*
10451042
* Record the current page ID: sweep will stop after this point.
@@ -1093,7 +1090,6 @@ __wt_las_sweep(WT_SESSION_IMPL *session)
10931090
WT_DECL_RET;
10941091
WT_ITEM las_key, las_timestamp, las_value;
10951092
WT_ITEM *sweep_key;
1096-
WT_TXN_ISOLATION saved_isolation;
10971093
#ifdef HAVE_TIMESTAMPS
10981094
wt_timestamp_t timestamp, *val_ts;
10991095
#else
@@ -1128,7 +1124,6 @@ __wt_las_sweep(WT_SESSION_IMPL *session)
11281124
*/
11291125
__wt_las_cursor(session, &cursor, &session_flags);
11301126
WT_ASSERT(session, cursor->session == &session->iface);
1131-
__las_set_isolation(session, &saved_isolation);
11321127
WT_ERR(__wt_txn_begin(session, NULL));
11331128
local_txn = true;
11341129

@@ -1323,7 +1318,6 @@ err: __wt_buf_free(session, sweep_key);
13231318
&cache->las_remove_count, remove_cnt);
13241319
}
13251320

1326-
__las_restore_isolation(session, saved_isolation);
13271321
WT_TRET(__wt_las_cursor_close(session, &cursor, session_flags));
13281322

13291323
if (locked)

src/third_party/wiredtiger/src/include/txn.i

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -784,32 +784,39 @@ __wt_txn_upd_visible(WT_SESSION_IMPL *session, WT_UPDATE *upd)
784784
static inline int
785785
__wt_txn_read(WT_SESSION_IMPL *session, WT_UPDATE *upd, WT_UPDATE **updp)
786786
{
787-
static WT_UPDATE tombstone = {
787+
static WT_UPDATE tombstone = {
788788
.txnid = WT_TXN_NONE, .type = WT_UPDATE_TOMBSTONE
789789
};
790-
WT_VISIBLE_TYPE upd_visible;
791-
bool skipped_birthmark;
792-
793-
*updp = NULL;
794-
for (skipped_birthmark = false; upd != NULL; upd = upd->next) {
795-
/* Skip reserved place-holders, they're never visible. */
796-
if (upd->type != WT_UPDATE_RESERVE) {
797-
upd_visible = __wt_txn_upd_visible_type(session, upd);
798-
if (upd_visible == WT_VISIBLE_TRUE)
799-
break;
800-
if (upd_visible == WT_VISIBLE_PREPARE)
801-
return (WT_PREPARE_CONFLICT);
802-
}
803-
/* An invisible birthmark is equivalent to a tombstone. */
804-
if (upd->type == WT_UPDATE_BIRTHMARK)
805-
skipped_birthmark = true;
790+
WT_VISIBLE_TYPE upd_visible;
791+
uint8_t type;
792+
bool skipped_birthmark;
793+
794+
*updp = NULL;
795+
796+
type = WT_UPDATE_INVALID; /* [-Wconditional-uninitialized] */
797+
for (skipped_birthmark = false; upd != NULL; upd = upd->next) {
798+
WT_ORDERED_READ(type, upd->type);
799+
800+
/* Skip reserved place-holders, they're never visible. */
801+
if (type != WT_UPDATE_RESERVE) {
802+
upd_visible = __wt_txn_upd_visible_type(session, upd);
803+
if (upd_visible == WT_VISIBLE_TRUE)
804+
break;
805+
if (upd_visible == WT_VISIBLE_PREPARE)
806+
return (WT_PREPARE_CONFLICT);
806807
}
807-
808-
if (upd == NULL && skipped_birthmark)
809-
upd = &tombstone;
810-
811-
*updp = upd == NULL || upd->type == WT_UPDATE_BIRTHMARK ? NULL : upd;
812-
return (0);
808+
/* An invisible birthmark is equivalent to a tombstone. */
809+
if (type == WT_UPDATE_BIRTHMARK)
810+
skipped_birthmark = true;
811+
}
812+
813+
if (upd == NULL && skipped_birthmark) {
814+
upd = &tombstone;
815+
type = upd->type;
816+
}
817+
818+
*updp = upd == NULL || type == WT_UPDATE_BIRTHMARK ? NULL : upd;
819+
return (0);
813820
}
814821

815822
/*

src/third_party/wiredtiger/src/reconcile/rec_write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,8 +1347,8 @@ __rec_append_orig_value(WT_SESSION_IMPL *session,
13471347
__wt_cache_page_inmem_incr(session, page, size);
13481348

13491349
if (upd->type == WT_UPDATE_BIRTHMARK) {
1350-
upd->type = WT_UPDATE_STANDARD;
1351-
upd->txnid = WT_TXN_ABORTED;
1350+
WT_PUBLISH(upd->txnid, WT_TXN_ABORTED);
1351+
WT_PUBLISH(upd->type, WT_UPDATE_STANDARD);
13521352
}
13531353

13541354
err: __wt_scr_free(session, &tmp);

src/third_party/wiredtiger/src/txn/txn_ckpt.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,23 +1205,36 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[], bool waiting)
12051205
static void
12061206
__drop(WT_CKPT *ckptbase, const char *name, size_t len)
12071207
{
1208-
WT_CKPT *ckpt;
1208+
WT_CKPT *ckpt;
1209+
u_int max_ckpt_drop;
12091210

1210-
/*
1211-
* If we're dropping internal checkpoints, match to the '.' separating
1211+
/*
1212+
* If we're dropping internal checkpoints, match to the '.' separating
12121213
* the checkpoint name from the generational number, and take all that
12131214
* we can find. Applications aren't allowed to use any variant of this
12141215
* name, so the test is still pretty simple, if the leading bytes match,
1215-
* it's one we want to drop.
1216-
*/
1217-
if (strncmp(WT_CHECKPOINT, name, len) == 0) {
1218-
WT_CKPT_FOREACH(ckptbase, ckpt)
1219-
if (WT_PREFIX_MATCH(ckpt->name, WT_CHECKPOINT))
1220-
F_SET(ckpt, WT_CKPT_DELETE);
1221-
} else
1222-
WT_CKPT_FOREACH(ckptbase, ckpt)
1223-
if (WT_STRING_MATCH(ckpt->name, name, len))
1224-
F_SET(ckpt, WT_CKPT_DELETE);
1216+
* it's one we want to drop.
1217+
*/
1218+
if (strncmp(WT_CHECKPOINT, name, len) == 0) {
1219+
/*
1220+
* Currently, hot backup cursors block checkpoint drop, which means
1221+
* releasing a hot backup cursor can result in immediately attempting
1222+
* to drop lots of checkpoints, which involves a fair amount of work
1223+
* while holding locks. Limit the number of standard checkpoints dropped
1224+
* per checkpoint.
1225+
*/
1226+
max_ckpt_drop = 0;
1227+
WT_CKPT_FOREACH (ckptbase, ckpt)
1228+
if (WT_PREFIX_MATCH(ckpt->name, WT_CHECKPOINT)) {
1229+
F_SET(ckpt, WT_CKPT_DELETE);
1230+
#define WT_MAX_CHECKPOINT_DROP 4
1231+
if (++max_ckpt_drop >= WT_MAX_CHECKPOINT_DROP)
1232+
break;
1233+
}
1234+
} else
1235+
WT_CKPT_FOREACH (ckptbase, ckpt)
1236+
if (WT_STRING_MATCH(ckpt->name, name, len))
1237+
F_SET(ckpt, WT_CKPT_DELETE);
12251238
}
12261239

12271240
/*

0 commit comments

Comments
 (0)