summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Petrel <etienne.petrel@mongodb.com>2022-09-01 14:23:45 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-01 15:05:20 +0000
commitf9fd4ff7a04219df87edd9d6084524eaf5616f10 (patch)
tree094caf4ec8eb6f0e2a0bc970ae20a8fa6e27e6a9
parent22f21e6e5a8086b3766485cc323ce9673587f30c (diff)
downloadmongo-f9fd4ff7a04219df87edd9d6084524eaf5616f10.tar.gz
Import wiredtiger: e217c5727a0922118d3d294729864605c2e8bacc from branch mongodb-master
ref: 0ac82ac3fb..e217c5727a for: 6.2.0-rc0 WT-9758 Only reset cursor bounds when calling cursor reset externally (#8208)
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/src/btree/bt_cursor.c13
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_file.c4
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_std.c6
-rw-r--r--src/third_party/wiredtiger/src/cursor/cur_table.c9
-rw-r--r--src/third_party/wiredtiger/src/include/api.h2
-rw-r--r--src/third_party/wiredtiger/src/include/cursor_inline.h25
-rw-r--r--src/third_party/wiredtiger/src/include/extern.h1
-rw-r--r--src/third_party/wiredtiger/src/include/wiredtiger.in1
-rw-r--r--src/third_party/wiredtiger/test/suite/test_cursor_bound14.py3
10 files changed, 49 insertions, 17 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index 2c0c864275e..2c0aa44d8aa 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-master",
- "commit": "0ac82ac3fb889ed948dcb23ef77b3cd82d6de935"
+ "commit": "e217c5727a0922118d3d294729864605c2e8bacc"
}
diff --git a/src/third_party/wiredtiger/src/btree/bt_cursor.c b/src/third_party/wiredtiger/src/btree/bt_cursor.c
index c410df4a76a..6b2d5bb60ca 100644
--- a/src/third_party/wiredtiger/src/btree/bt_cursor.c
+++ b/src/third_party/wiredtiger/src/btree/bt_cursor.c
@@ -611,19 +611,6 @@ __wt_btcur_reset(WT_CURSOR_BTREE *cbt)
WT_STAT_CONN_DATA_INCR(session, cursor_reset);
- /* Clear bounds if they are set. */
- if (F_ISSET(cursor, WT_CURSTD_BOUNDS_SET)) {
- WT_STAT_CONN_DATA_INCR(session, cursor_bounds_reset);
- /* Clear upper bound, and free the buffer. */
- F_CLR(cursor, WT_CURSTD_BOUND_UPPER | WT_CURSTD_BOUND_UPPER_INCLUSIVE);
- __wt_buf_free(session, &cursor->upper_bound);
- WT_CLEAR(cursor->upper_bound);
- /* Clear lower bound, and free the buffer. */
- F_CLR(cursor, WT_CURSTD_BOUND_LOWER | WT_CURSTD_BOUND_LOWER_INCLUSIVE);
- __wt_buf_free(session, &cursor->lower_bound);
- WT_CLEAR(cursor->lower_bound);
- }
-
F_CLR(cursor, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET);
return (__cursor_reset(cbt));
diff --git a/src/third_party/wiredtiger/src/cursor/cur_file.c b/src/third_party/wiredtiger/src/cursor/cur_file.c
index 20cc8145c48..490cfc3d49a 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_file.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_file.c
@@ -275,6 +275,10 @@ __curfile_reset(WT_CURSOR *cursor)
ret = __wt_btcur_reset(cbt);
+ /* If a user calls cursor reset also reset the bounds. */
+ if (API_USER_ENTRY(session))
+ __wt_cursor_bound_reset(cursor);
+
/* Reset maintains no position, key or value. */
WT_ASSERT(session,
!F_ISSET(cbt, WT_CBT_ACTIVE) && F_MASK(cursor, WT_CURSTD_KEY_SET) == 0 &&
diff --git a/src/third_party/wiredtiger/src/cursor/cur_std.c b/src/third_party/wiredtiger/src/cursor/cur_std.c
index ff8131d5167..b047c06221c 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_std.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_std.c
@@ -651,6 +651,12 @@ __wt_cursor_cache(WT_CURSOR *cursor, WT_DATA_HANDLE *dhandle)
WT_TRET(cursor->reset(cursor));
+ /*
+ * Cursor reset clears bounds on cursors when called externally, we need to clear the bounds
+ * manually when we cache a cursor.
+ */
+ __wt_cursor_bound_reset(cursor);
+
/* Don't keep buffers allocated for cached cursors. */
__wt_buf_free(session, &cursor->key);
__wt_buf_free(session, &cursor->value);
diff --git a/src/third_party/wiredtiger/src/cursor/cur_table.c b/src/third_party/wiredtiger/src/cursor/cur_table.c
index d82b3c6e731..331c54e0418 100644
--- a/src/third_party/wiredtiger/src/cursor/cur_table.c
+++ b/src/third_party/wiredtiger/src/cursor/cur_table.c
@@ -433,14 +433,23 @@ err:
static int
__curtable_reset(WT_CURSOR *cursor)
{
+ WT_CURSOR *primary;
WT_CURSOR_TABLE *ctable;
WT_DECL_RET;
WT_SESSION_IMPL *session;
ctable = (WT_CURSOR_TABLE *)cursor;
+ /* Grab the primary cursor to reset the bounds. */
+ primary = *ctable->cg_cursors;
+
JOINABLE_CURSOR_API_CALL_PREPARE_ALLOWED(cursor, session, reset, NULL);
+
APPLY_CG(ctable, reset);
+ /* If a user calls cursor reset also reset the bounds. */
+ if (API_USER_ENTRY(session))
+ __wt_cursor_bound_reset(primary);
+
err:
API_END_RET(session, ret);
}
diff --git a/src/third_party/wiredtiger/src/include/api.h b/src/third_party/wiredtiger/src/include/api.h
index ca419ab5143..b34d41a8167 100644
--- a/src/third_party/wiredtiger/src/include/api.h
+++ b/src/third_party/wiredtiger/src/include/api.h
@@ -189,6 +189,8 @@
API_END(s, 0); \
return ((ret) == WT_NOTFOUND ? ENOENT : (ret))
+#define API_USER_ENTRY(s) (s)->api_call_counter == 1
+
#define CONNECTION_API_CALL(conn, s, n, config, cfg) \
s = (conn)->default_session; \
API_CALL(s, WT_CONNECTION, n, NULL, config, cfg)
diff --git a/src/third_party/wiredtiger/src/include/cursor_inline.h b/src/third_party/wiredtiger/src/include/cursor_inline.h
index b16b2086e53..126a942721d 100644
--- a/src/third_party/wiredtiger/src/include/cursor_inline.h
+++ b/src/third_party/wiredtiger/src/include/cursor_inline.h
@@ -75,6 +75,31 @@ __cursor_novalue(WT_CURSOR *cursor)
}
/*
+ * __wt_cursor_bound_reset --
+ * Clear any bounds on the cursor if they are set.
+ */
+static inline void
+__wt_cursor_bound_reset(WT_CURSOR *cursor)
+{
+ WT_SESSION_IMPL *session;
+
+ session = CUR2S(cursor);
+
+ /* Clear bounds if they are set. */
+ if (WT_CURSOR_BOUNDS_SET(cursor)) {
+ WT_STAT_CONN_DATA_INCR(session, cursor_bounds_reset);
+ /* Clear upper bound, and free the buffer. */
+ F_CLR(cursor, WT_CURSTD_BOUND_UPPER | WT_CURSTD_BOUND_UPPER_INCLUSIVE);
+ __wt_buf_free(session, &cursor->upper_bound);
+ WT_CLEAR(cursor->upper_bound);
+ /* Clear lower bound, and free the buffer. */
+ F_CLR(cursor, WT_CURSTD_BOUND_LOWER | WT_CURSTD_BOUND_LOWER_INCLUSIVE);
+ __wt_buf_free(session, &cursor->lower_bound);
+ WT_CLEAR(cursor->lower_bound);
+ }
+}
+
+/*
* __cursor_checkkey --
* Check if a key is set without making a copy.
*/
diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h
index 470e83000c2..987df757b05 100644
--- a/src/third_party/wiredtiger/src/include/extern.h
+++ b/src/third_party/wiredtiger/src/include/extern.h
@@ -2363,6 +2363,7 @@ static inline void __wt_cell_unpack_kv(WT_SESSION_IMPL *session, const WT_PAGE_H
WT_CELL *cell, WT_CELL_UNPACK_KV *unpack_value);
static inline void __wt_cond_wait(
WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool (*run_func)(WT_SESSION_IMPL *));
+static inline void __wt_cursor_bound_reset(WT_CURSOR *cursor);
static inline void __wt_cursor_dhandle_decr_use(WT_SESSION_IMPL *session);
static inline void __wt_cursor_dhandle_incr_use(WT_SESSION_IMPL *session);
static inline void __wt_epoch(WT_SESSION_IMPL *session, struct timespec *tsp);
diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in
index c88df1b9a6d..1b460ed6602 100644
--- a/src/third_party/wiredtiger/src/include/wiredtiger.in
+++ b/src/third_party/wiredtiger/src/include/wiredtiger.in
@@ -781,7 +781,6 @@ struct __wt_cursor {
/* AUTOMATIC FLAG VALUE GENERATION STOP 64 */
#define WT_CURSTD_KEY_SET (WT_CURSTD_KEY_EXT | WT_CURSTD_KEY_INT)
#define WT_CURSTD_VALUE_SET (WT_CURSTD_VALUE_EXT | WT_CURSTD_VALUE_INT)
-#define WT_CURSTD_BOUNDS_SET (WT_CURSTD_BOUND_LOWER | WT_CURSTD_BOUND_UPPER)
uint64_t flags;
#endif
};
diff --git a/src/third_party/wiredtiger/test/suite/test_cursor_bound14.py b/src/third_party/wiredtiger/test/suite/test_cursor_bound14.py
index 350a77faebc..27364976af0 100644
--- a/src/third_party/wiredtiger/test/suite/test_cursor_bound14.py
+++ b/src/third_party/wiredtiger/test/suite/test_cursor_bound14.py
@@ -39,8 +39,7 @@ class test_cursor_bound14(bound_base):
types = [
('file', dict(uri='file:', use_colgroup=False)),
('table', dict(uri='table:', use_colgroup=False)),
- # FIXME-WT-9738: Uncomment once bug with remove operations on a bounded cursor with colgroups is fixed.
- #('colgroup', dict(uri='table:', use_colgroup=True))
+ ('colgroup', dict(uri='table:', use_colgroup=True))
]
key_formats = [