Skip to content

Commit

Permalink
Revert "WT-6816 Design write gen scheme to allow dhandles with active…
Browse files Browse the repository at this point in the history
… history to get closed/re-opened (#6085)" (#6111)

This reverts commit 9c0d479.
  • Loading branch information
tetsuo-cpp committed Nov 4, 2020
1 parent 9818e43 commit c18b6fc
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 170 deletions.
1 change: 0 additions & 1 deletion dist/s_string.ok
Expand Up @@ -346,7 +346,6 @@ Redistributions
Refactor
Resize
RocksDB
Runtime
SIMD
SLIST
SLVG
Expand Down
45 changes: 8 additions & 37 deletions src/btree/bt_handle.c
Expand Up @@ -522,45 +522,16 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt)
btree->checkpoint_gen = __wt_gen(session, WT_GEN_CHECKPOINT); /* Checkpoint generation */

/*
* The first time we open a btree, we'll be initializing the write gen to the connection-wide
* base write generation since this is the largest of all btree write generations from the
* previous run. This has the nice property of ensuring that the range of write generations used
* by consecutive runs do not overlap which aids with debugging.
* In the regular case, we'll be initializing to the connection-wide base write generation since
* this is the largest of all btree write generations from the previous run. This has the nice
* property of ensuring that the range of write generations used by consecutive runs do not
* overlap which aids with debugging.
*
* If we're reopening a btree or importing a new one to a running system, the btree write
* generation from the last run may actually be ahead of the connection-wide base write
* generation. In that case, we should initialize our write gen just ahead of our btree specific
* write generation.
*
* The runtime write generation is important since it's going to determine what we're going to
* use as the base write generation (and thus what pages to wipe transaction ids from). The idea
* is that we want to initialize it once the first time we open the btree during a run and then
* for every subsequent open, we want to reuse it. This so that we're still able to read
* transaction ids from the previous time a btree was open in the same run.
*
* FIXME-WT-6819: When we begin discarding dhandles more aggressively, we need to check that
* updates aren't having their transaction ids wiped after reopening the dhandle. The runtime
* write generation is relevant here since it should remain static across the entire run.
*/
btree->write_gen = WT_MAX(ckpt->write_gen, conn->base_write_gen) + 1;
WT_ASSERT(session, ckpt->write_gen >= ckpt->run_write_gen);

/* If this is the first time opening the tree this run. */
if (F_ISSET(session, WT_SESSION_IMPORT) || ckpt->run_write_gen <= conn->base_write_gen)
btree->base_write_gen = btree->run_write_gen = btree->write_gen;
else
btree->base_write_gen = btree->run_write_gen = ckpt->run_write_gen;

/*
* We've just overwritten the runtime write generation based off the fact that know that we're
* importing and therefore, the checkpoint data's runtime write generation is meaningless. We
* need to ensure that the underlying dhandle doesn't get discarded without being included in a
* subsequent checkpoint including the new overwritten runtime write generation. Otherwise,
* we'll reopen, won't know that we're in the import case and will incorrectly use the old
* system's runtime write generation.
* In the import case, the btree write generation from the last run may actually be ahead of the
* connection-wide base write generation. In that case, we should initialize our write gen just
* ahead of our btree specific write generation.
*/
if (F_ISSET(session, WT_SESSION_IMPORT))
btree->modified = true;
btree->write_gen = btree->base_write_gen = WT_MAX(ckpt->write_gen + 1, conn->base_write_gen);

return (0);
}
Expand Down
1 change: 0 additions & 1 deletion src/include/btree.h
Expand Up @@ -168,7 +168,6 @@ struct __wt_btree {

uint64_t write_gen; /* Write generation */
uint64_t base_write_gen; /* Write generation on startup. */
uint64_t run_write_gen; /* Runtime write generation. */
uint64_t rec_max_txn; /* Maximum txn seen (clean trees) */
wt_timestamp_t rec_max_timestamp;

Expand Down
3 changes: 1 addition & 2 deletions src/include/meta.h
Expand Up @@ -137,8 +137,7 @@ struct __wt_ckpt {

uint64_t size; /* Checkpoint size */

uint64_t write_gen; /* Write generation */
uint64_t run_write_gen; /* Runtime write generation. */
uint64_t write_gen; /* Write generation */

char *block_metadata; /* Block-stored metadata */
char *block_checkpoint; /* Block-stored checkpoint */
Expand Down
51 changes: 25 additions & 26 deletions src/include/session.h
Expand Up @@ -170,32 +170,31 @@ struct __wt_session_impl {
#define WT_SESSION_CACHE_CURSORS 0x00000004u
#define WT_SESSION_CAN_WAIT 0x00000008u
#define WT_SESSION_IGNORE_CACHE_SIZE 0x00000010u
#define WT_SESSION_IMPORT 0x00000020u
#define WT_SESSION_IMPORT_REPAIR 0x00000040u
#define WT_SESSION_INSTANTIATE_PREPARE 0x00000080u
#define WT_SESSION_INTERNAL 0x00000100u
#define WT_SESSION_LOCKED_CHECKPOINT 0x00000200u
#define WT_SESSION_LOCKED_HANDLE_LIST_READ 0x00000400u
#define WT_SESSION_LOCKED_HANDLE_LIST_WRITE 0x00000800u
#define WT_SESSION_LOCKED_HOTBACKUP_READ 0x00001000u
#define WT_SESSION_LOCKED_HOTBACKUP_WRITE 0x00002000u
#define WT_SESSION_LOCKED_METADATA 0x00004000u
#define WT_SESSION_LOCKED_PASS 0x00008000u
#define WT_SESSION_LOCKED_SCHEMA 0x00010000u
#define WT_SESSION_LOCKED_SLOT 0x00020000u
#define WT_SESSION_LOCKED_TABLE_READ 0x00040000u
#define WT_SESSION_LOCKED_TABLE_WRITE 0x00080000u
#define WT_SESSION_LOCKED_TURTLE 0x00100000u
#define WT_SESSION_LOGGING_INMEM 0x00200000u
#define WT_SESSION_NO_DATA_HANDLES 0x00400000u
#define WT_SESSION_NO_LOGGING 0x00800000u
#define WT_SESSION_NO_RECONCILE 0x01000000u
#define WT_SESSION_NO_SCHEMA_LOCK 0x02000000u
#define WT_SESSION_QUIET_CORRUPT_FILE 0x04000000u
#define WT_SESSION_READ_WONT_NEED 0x08000000u
#define WT_SESSION_RESOLVING_TXN 0x10000000u
#define WT_SESSION_ROLLBACK_TO_STABLE 0x20000000u
#define WT_SESSION_SCHEMA_TXN 0x40000000u
#define WT_SESSION_IMPORT_REPAIR 0x00000020u
#define WT_SESSION_INSTANTIATE_PREPARE 0x00000040u
#define WT_SESSION_INTERNAL 0x00000080u
#define WT_SESSION_LOCKED_CHECKPOINT 0x00000100u
#define WT_SESSION_LOCKED_HANDLE_LIST_READ 0x00000200u
#define WT_SESSION_LOCKED_HANDLE_LIST_WRITE 0x00000400u
#define WT_SESSION_LOCKED_HOTBACKUP_READ 0x00000800u
#define WT_SESSION_LOCKED_HOTBACKUP_WRITE 0x00001000u
#define WT_SESSION_LOCKED_METADATA 0x00002000u
#define WT_SESSION_LOCKED_PASS 0x00004000u
#define WT_SESSION_LOCKED_SCHEMA 0x00008000u
#define WT_SESSION_LOCKED_SLOT 0x00010000u
#define WT_SESSION_LOCKED_TABLE_READ 0x00020000u
#define WT_SESSION_LOCKED_TABLE_WRITE 0x00040000u
#define WT_SESSION_LOCKED_TURTLE 0x00080000u
#define WT_SESSION_LOGGING_INMEM 0x00100000u
#define WT_SESSION_NO_DATA_HANDLES 0x00200000u
#define WT_SESSION_NO_LOGGING 0x00400000u
#define WT_SESSION_NO_RECONCILE 0x00800000u
#define WT_SESSION_NO_SCHEMA_LOCK 0x01000000u
#define WT_SESSION_QUIET_CORRUPT_FILE 0x02000000u
#define WT_SESSION_READ_WONT_NEED 0x04000000u
#define WT_SESSION_RESOLVING_TXN 0x08000000u
#define WT_SESSION_ROLLBACK_TO_STABLE 0x10000000u
#define WT_SESSION_SCHEMA_TXN 0x20000000u
/* AUTOMATIC FLAG VALUE GENERATION STOP */
uint32_t flags;

Expand Down
15 changes: 2 additions & 13 deletions src/meta/meta_ckpt.c
Expand Up @@ -697,16 +697,6 @@ __ckpt_load(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *k, WT_CONFIG_ITEM *v, WT_C
goto format;
ckpt->write_gen = (uint64_t)a.val;

/*
* If runtime write generation isn't supplied, this means that we're doing an upgrade and that
* we're opening the tree for the first time. We should just leave it as 0 so it is recognized
* as part of a previous run.
*/
ret = __wt_config_subgets(session, v, "run_write_gen", &a);
WT_RET_NOTFOUND_OK(ret);
if (ret != WT_NOTFOUND && a.len != 0)
ckpt->run_write_gen = (uint64_t)a.val;

return (0);

format:
Expand Down Expand Up @@ -799,13 +789,12 @@ __wt_meta_ckptlist_to_meta(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, WT_ITEM
"=(addr=\"%.*s\",order=%" PRId64 ",time=%" PRIu64 ",size=%" PRId64
",newest_start_durable_ts=%" PRId64 ",oldest_start_ts=%" PRId64 ",newest_txn=%" PRId64
",newest_stop_durable_ts=%" PRId64 ",newest_stop_ts=%" PRId64 ",newest_stop_txn=%" PRId64
",prepare=%d,write_gen=%" PRId64 ",run_write_gen=%" PRId64 ")",
",prepare=%d,write_gen=%" PRId64 ")",
(int)ckpt->addr.size, (char *)ckpt->addr.data, ckpt->order, ckpt->sec,
(int64_t)ckpt->size, (int64_t)ckpt->ta.newest_start_durable_ts,
(int64_t)ckpt->ta.oldest_start_ts, (int64_t)ckpt->ta.newest_txn,
(int64_t)ckpt->ta.newest_stop_durable_ts, (int64_t)ckpt->ta.newest_stop_ts,
(int64_t)ckpt->ta.newest_stop_txn, (int)ckpt->ta.prepare, (int64_t)ckpt->write_gen,
(int64_t)ckpt->run_write_gen));
(int64_t)ckpt->ta.newest_stop_txn, (int)ckpt->ta.prepare, (int64_t)ckpt->write_gen));
}
WT_RET(__wt_buf_catfmt(session, buf, ")"));

Expand Down
3 changes: 0 additions & 3 deletions src/schema/schema_create.c
Expand Up @@ -798,8 +798,6 @@ __schema_create(WT_SESSION_IMPL *session, const char *uri, const char *config)
* back it all out.
*/
WT_RET(__wt_meta_track_on(session));
if (import)
F_SET(session, WT_SESSION_IMPORT);

if (WT_PREFIX_MATCH(uri, "colgroup:"))
ret = __create_colgroup(session, uri, exclusive, config);
Expand All @@ -818,7 +816,6 @@ __schema_create(WT_SESSION_IMPL *session, const char *uri, const char *config)
ret = __wt_bad_object_type(session, uri);

session->dhandle = NULL;
F_CLR(session, WT_SESSION_IMPORT);
WT_TRET(__wt_meta_track_off(session, true, ret != 0));

return (ret);
Expand Down
1 change: 0 additions & 1 deletion src/txn/txn_ckpt.c
Expand Up @@ -1580,7 +1580,6 @@ __wt_checkpoint_tree_reconcile_update(WT_SESSION_IMPL *session, WT_TIME_AGGREGAT
WT_CKPT_FOREACH (ckptbase, ckpt)
if (F_ISSET(ckpt, WT_CKPT_ADD)) {
ckpt->write_gen = btree->write_gen;
ckpt->run_write_gen = btree->run_write_gen;
WT_TIME_AGGREGATE_COPY(&ckpt->ta, ta);
}
}
Expand Down
86 changes: 0 additions & 86 deletions test/suite/test_txn25.py

This file was deleted.

0 comments on commit c18b6fc

Please sign in to comment.