diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2016-12-05 11:49:34 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-05 11:49:34 +1100 |
commit | 2f18a859cea47f0352cea9fbd64b396e52095ed8 (patch) | |
tree | f0f1fe9b405c917d17f2e51ec971571e6ec5a102 /test/suite/test_nsnap04.py | |
parent | 2573977de124b397f1e3564b6554f3c97fcfe6fa (diff) | |
download | mongo-2f18a859cea47f0352cea9fbd64b396e52095ed8.tar.gz |
WT-3034 Add support for named snapshots including updates. (#3161)
This supports a model where one session performs updates in a transaction after creating a named snapshot and other sessions can use that snapshot and read the updates. In other words, they see exactly what the updating session sees.
Diffstat (limited to 'test/suite/test_nsnap04.py')
-rw-r--r-- | test/suite/test_nsnap04.py | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/test/suite/test_nsnap04.py b/test/suite/test_nsnap04.py index 60901dd2ee3..8d491540d74 100644 --- a/test/suite/test_nsnap04.py +++ b/test/suite/test_nsnap04.py @@ -38,14 +38,18 @@ class test_nsnap04(wttest.WiredTigerTestCase, suite_subprocess): uri = 'table:' + tablename nrows_per_itr = 10 - def check_named_snapshot(self, snapshot, expected): + def check_named_snapshot(self, snapshot, expected, skip_snapshot=False): new_session = self.conn.open_session() c = new_session.open_cursor(self.uri) - new_session.begin_transaction("snapshot=" + str(snapshot)) + if skip_snapshot: + new_session.begin_transaction() + else: + new_session.begin_transaction("snapshot=" + str(snapshot)) count = 0 for row in c: count += 1 new_session.commit_transaction() + new_session.close() # print "Checking snapshot %d, expect %d, found %d" % (snapshot, expected, count) self.assertEqual(count, expected) @@ -80,5 +84,34 @@ class test_nsnap04(wttest.WiredTigerTestCase, suite_subprocess): self.session.snapshot("name=0") self.check_named_snapshot(0, 2 * self.nrows_per_itr) + def test_include_updates(self): + # Populate a table + end = start = 0 + SimpleDataSet(self, self.uri, 0, key_format='i').populate() + + snapshots = [] + c = self.session.open_cursor(self.uri) + for i in xrange(self.nrows_per_itr): + c[i] = "some value" + + self.session.begin_transaction("isolation=snapshot") + count = 0 + for row in c: + count += 1 + self.session.snapshot("name=0,include_updates=true") + + self.check_named_snapshot(0, self.nrows_per_itr) + + # Insert some more content using the active session. + for i in xrange(self.nrows_per_itr): + c[self.nrows_per_itr + i] = "some value" + + self.check_named_snapshot(0, 2 * self.nrows_per_itr) + # Ensure transactions not tracking the snapshot don't see the updates + self.check_named_snapshot(0, self.nrows_per_itr, skip_snapshot=True) + self.session.commit_transaction() + # Ensure content is visible to non-snapshot transactions after commit + self.check_named_snapshot(0, 2 * self.nrows_per_itr, skip_snapshot=True) + if __name__ == '__main__': wttest.run() |