summaryrefslogtreecommitdiff
path: root/src/btree/bt_sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/btree/bt_sync.c')
-rw-r--r--src/btree/bt_sync.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c
index 939d8f808b1..5d5ad491145 100644
--- a/src/btree/bt_sync.c
+++ b/src/btree/bt_sync.c
@@ -22,16 +22,17 @@ __sync_file(WT_SESSION_IMPL *session, int syncop)
WT_PAGE_MODIFY *mod;
WT_REF *walk;
WT_TXN *txn;
- uint64_t internal_bytes, leaf_bytes;
- uint64_t internal_pages, leaf_pages;
+ uint64_t internal_bytes, internal_pages, leaf_bytes, leaf_pages;
+ uint64_t saved_snap_min;
uint32_t flags;
bool evict_reset;
btree = S2BT(session);
- flags = WT_READ_CACHE | WT_READ_NO_GEN;
walk = NULL;
txn = &session->txn;
+ saved_snap_min = WT_SESSION_TXN_STATE(session)->snap_min;
+ flags = WT_READ_CACHE | WT_READ_NO_GEN;
internal_bytes = leaf_bytes = 0;
internal_pages = leaf_pages = 0;
@@ -80,6 +81,19 @@ __sync_file(WT_SESSION_IMPL *session, int syncop)
break;
case WT_SYNC_CHECKPOINT:
/*
+ * If we are flushing a file at read-committed isolation, which
+ * is of particular interest for flushing the metadata to make
+ * schema-changing operation durable, get a transactional
+ * snapshot now.
+ *
+ * All changes committed up to this point should be included.
+ * We don't update the snapshot in between pages because (a)
+ * the metadata shouldn't be that big, and (b) if we do ever
+ */
+ if (txn->isolation == WT_ISO_READ_COMMITTED)
+ __wt_txn_get_snapshot(session);
+
+ /*
* We cannot check the tree modified flag in the case of a
* checkpoint, the checkpoint code has already cleared it.
*
@@ -185,7 +199,12 @@ err: /* On error, clear any left-over tree walk. */
if (walk != NULL)
WT_TRET(__wt_page_release(session, walk, flags));
- if (txn->isolation == WT_ISO_READ_COMMITTED && session->ncursors == 0)
+ /*
+ * If we got a snapshot in order to write pages, and there was no
+ * snapshot active when we started, release it.
+ */
+ if (txn->isolation == WT_ISO_READ_COMMITTED &&
+ saved_snap_min == WT_TXN_NONE)
__wt_txn_release_snapshot(session);
if (btree->checkpointing) {