diff options
author | Luke Chen <luke.chen@mongodb.com> | 2020-09-22 16:11:11 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-22 06:35:27 +0000 |
commit | 2e51850ef5456cfaa7f43fe271c78bcc5f399104 (patch) | |
tree | 95f2728a14cd416cc51743ecc7d4fbadbc426655 /src/third_party | |
parent | c39d807293012fcad6a2522cba4f7a19026ad2a5 (diff) | |
download | mongo-2e51850ef5456cfaa7f43fe271c78bcc5f399104.tar.gz |
Import wiredtiger: 0885446e1962dc26ed35adf684bc91893965fbbf from branch mongodb-4.6
ref: 472039bd1c..0885446e19
for: 4.8.0
WT-6657 Fix history store panic when inserting an update without timestamp
Diffstat (limited to 'src/third_party')
-rw-r--r-- | src/third_party/wiredtiger/import.data | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/history/hs.c | 12 | ||||
-rw-r--r-- | src/third_party/wiredtiger/test/suite/test_hs16.py | 72 |
3 files changed, 81 insertions, 5 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data index 5ffef917cfd..087648da7a7 100644 --- a/src/third_party/wiredtiger/import.data +++ b/src/third_party/wiredtiger/import.data @@ -2,5 +2,5 @@ "vendor": "wiredtiger", "github": "wiredtiger/wiredtiger.git", "branch": "mongodb-4.6", - "commit": "472039bd1c9fd31f22730ba25afc23f4b09f59a8" + "commit": "0885446e1962dc26ed35adf684bc91893965fbbf" } diff --git a/src/third_party/wiredtiger/src/history/hs.c b/src/third_party/wiredtiger/src/history/hs.c index a7ac8003228..f7588ca35c0 100644 --- a/src/third_party/wiredtiger/src/history/hs.c +++ b/src/third_party/wiredtiger/src/history/hs.c @@ -898,15 +898,19 @@ __wt_hs_insert_updates(WT_SESSION_IMPL *session, WT_PAGE *page, WT_MULTI *multi) continue; } - /* Skip updates that are already in the history store or are obsolete. */ - if (F_ISSET(upd, WT_UPDATE_HS | WT_UPDATE_OBSOLETE)) { + /* Skip updates that are already in the history store. */ + if (F_ISSET(upd, WT_UPDATE_HS)) { if (hs_inserted) WT_ERR_PANIC(session, WT_PANIC, - "Inserting updates older than obsolete updates or updates that are already " - "in the history store to the history store may corrupt the data."); + "Reinserting updates to the history store may corrupt the data as it may " + "clear the history store data newer than it."); continue; } + /* Skip updates that are obsolete. */ + if (F_ISSET(upd, WT_UPDATE_OBSOLETE)) + continue; + /* * If the time points are out of order (which can happen if the application performs * updates with out-of-order timestamps), so this value can never be seen, don't bother diff --git a/src/third_party/wiredtiger/test/suite/test_hs16.py b/src/third_party/wiredtiger/test/suite/test_hs16.py new file mode 100644 index 00000000000..1e5da4a19a1 --- /dev/null +++ b/src/third_party/wiredtiger/test/suite/test_hs16.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# +# Public Domain 2014-2020 MongoDB, Inc. +# Public Domain 2008-2014 WiredTiger, Inc. +# +# This is free and unencumbered software released into the public domain. +# +# Anyone is free to copy, modify, publish, use, compile, sell, or +# distribute this software, either in source code form or as a compiled +# binary, for any purpose, commercial or non-commercial, and by any +# means. +# +# In jurisdictions that recognize copyright laws, the author or authors +# of this software dedicate any and all copyright interest in the +# software to the public domain. We make this dedication for the benefit +# of the public at large and to the detriment of our heirs and +# successors. We intend this dedication to be an overt act of +# relinquishment in perpetuity of all present and future rights to this +# software under copyright law. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +import time, wiredtiger, wttest + +def timestamp_str(t): + return '%x' % t + +# test_hs16.py +# Ensure that we don't panic when inserting an update without timestamp to the history store. +class test_hs16(wttest.WiredTigerTestCase): + conn_config = 'cache_size=5MB' + session_config = 'isolation=snapshot' + + def test_hs16(self): + uri = 'table:test_hs16' + self.session.create(uri, 'key_format=S,value_format=S') + cursor = self.session.open_cursor(uri) + + # Insert an update without timestamp + self.session.begin_transaction() + cursor[str(0)] = 'a' + self.session.commit_transaction() + + # Update an update at timestamp 1 + self.session.begin_transaction() + cursor[str(0)] = 'b' + self.session.commit_transaction('commit_timestamp=' + timestamp_str(1)) + + # Open anther session to make the next update without timestamp non-globally visible + session2 = self.setUpSessionOpen(self.conn) + cursor2 = session2.open_cursor(uri) + session2.begin_transaction() + cursor[str(1)] = 'a' + + # Update an update without timestamp + self.session.begin_transaction() + cursor[str(0)] = 'c' + self.session.commit_transaction() + + # Update an update at timestamp 2 + self.session.begin_transaction() + cursor[str(0)] = 'd' + self.session.commit_transaction('commit_timestamp=' + timestamp_str(2)) + + # Do a checkpoint, it should not panic + self.session.checkpoint() |