diff options
Diffstat (limited to 'src/third_party/wiredtiger/src/include')
-rw-r--r-- | src/third_party/wiredtiger/src/include/api.h | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/btmem.h | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/cursor.h | 21 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/cursor.i | 14 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/extern.h | 2 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/mutex.h | 5 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/stat.h | 3 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/txn.h | 1 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/txn.i | 94 | ||||
-rw-r--r-- | src/third_party/wiredtiger/src/include/wiredtiger.in | 71 |
10 files changed, 151 insertions, 64 deletions
diff --git a/src/third_party/wiredtiger/src/include/api.h b/src/third_party/wiredtiger/src/include/api.h index afefbe8ad5c..ff757c4bfb5 100644 --- a/src/third_party/wiredtiger/src/include/api.h +++ b/src/third_party/wiredtiger/src/include/api.h @@ -68,6 +68,7 @@ if ((ret) != 0 && \ (ret) != WT_NOTFOUND && \ (ret) != WT_DUPLICATE_KEY && \ + (ret) != WT_PREPARE_CONFLICT && \ F_ISSET(&(s)->txn, WT_TXN_RUNNING)) \ F_SET(&(s)->txn, WT_TXN_ERROR); \ /* \ @@ -237,6 +238,7 @@ JOINABLE_CURSOR_CALL_CHECK(cur) #define CURSOR_UPDATE_API_END(s, ret) \ + ((ret == WT_PREPARE_CONFLICT) ? (ret = WT_ROLLBACK) : ret ); \ TXN_API_END(s, ret) #define ASYNCOP_API_CALL(conn, s, n) \ diff --git a/src/third_party/wiredtiger/src/include/btmem.h b/src/third_party/wiredtiger/src/include/btmem.h index 7ba73d1b94f..d56a3773933 100644 --- a/src/third_party/wiredtiger/src/include/btmem.h +++ b/src/third_party/wiredtiger/src/include/btmem.h @@ -997,7 +997,7 @@ struct __wt_update { finalized prepare */ #define WT_UPDATE_STATE_LOCKED 1 /* locked */ #define WT_UPDATE_STATE_PREPARED 2 /* prepared */ - uint8_t state; /* state (one byte : conserve memory) */ + volatile uint8_t state; /* If the update includes a complete value. */ #define WT_UPDATE_DATA_VALUE(upd) \ diff --git a/src/third_party/wiredtiger/src/include/cursor.h b/src/third_party/wiredtiger/src/include/cursor.h index 70f9318f6d7..ec5c6689c3f 100644 --- a/src/third_party/wiredtiger/src/include/cursor.h +++ b/src/third_party/wiredtiger/src/include/cursor.h @@ -217,20 +217,23 @@ struct __wt_cursor_btree { #endif /* AUTOMATIC FLAG VALUE GENERATION START */ -#define WT_CBT_ACTIVE 0x01u /* Active in the tree */ -#define WT_CBT_ITERATE_APPEND 0x02u /* Col-store: iterating append list */ -#define WT_CBT_ITERATE_NEXT 0x04u /* Next iteration configuration */ -#define WT_CBT_ITERATE_PREV 0x08u /* Prev iteration configuration */ -#define WT_CBT_NO_TXN 0x10u /* Non-txn cursor (e.g. a checkpoint) */ -#define WT_CBT_SEARCH_SMALLEST 0x20u /* Row-store: small-key insert list */ -#define WT_CBT_VAR_ONPAGE_MATCH 0x40u /* Var-store: on-page recno match */ +#define WT_CBT_ACTIVE 0x001u /* Active in the tree */ +#define WT_CBT_ITERATE_APPEND 0x002u /* Col-store: iterating append list */ +#define WT_CBT_ITERATE_NEXT 0x004u /* Next iteration configuration */ +#define WT_CBT_ITERATE_PREV 0x008u /* Prev iteration configuration */ +#define WT_CBT_NO_TXN 0x010u /* Non-txn cursor (e.g. a checkpoint) */ +#define WT_CBT_RETRY_NEXT 0x020u /* Next, resulted in prepare conflict */ +#define WT_CBT_RETRY_PREV 0x040u /* Prev, resulted in prepare conflict */ +#define WT_CBT_SEARCH_SMALLEST 0x080u /* Row-store: small-key insert list */ +#define WT_CBT_VAR_ONPAGE_MATCH 0x100u /* Var-store: on-page recno match */ /* AUTOMATIC FLAG VALUE GENERATION STOP */ #define WT_CBT_POSITION_MASK /* Flags associated with position */ \ (WT_CBT_ITERATE_APPEND | WT_CBT_ITERATE_NEXT | WT_CBT_ITERATE_PREV | \ - WT_CBT_SEARCH_SMALLEST | WT_CBT_VAR_ONPAGE_MATCH) + WT_CBT_RETRY_NEXT | WT_CBT_RETRY_PREV | WT_CBT_SEARCH_SMALLEST | \ + WT_CBT_VAR_ONPAGE_MATCH) - uint8_t flags; + uint32_t flags; }; struct __wt_cursor_bulk { diff --git a/src/third_party/wiredtiger/src/include/cursor.i b/src/third_party/wiredtiger/src/include/cursor.i index a4e986c4325..d338c47dfae 100644 --- a/src/third_party/wiredtiger/src/include/cursor.i +++ b/src/third_party/wiredtiger/src/include/cursor.i @@ -311,6 +311,20 @@ __wt_cursor_dhandle_decr_use(WT_SESSION_IMPL *session) } /* + * __cursor_kv_return -- + * Return a page referenced key/value pair to the application. + */ +static inline int +__cursor_kv_return( + WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_UPDATE *upd) +{ + WT_RET(__wt_key_return(session, cbt)); + WT_RET(__wt_value_return(session, cbt, upd)); + + return (0); +} + +/* * __cursor_func_init -- * Cursor call setup. */ diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index 8b69f9ef244..508480b95c2 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -100,7 +100,7 @@ extern void __wt_cursor_key_order_reset(WT_CURSOR_BTREE *cbt); extern void __wt_btcur_iterate_setup(WT_CURSOR_BTREE *cbt); extern int __wt_btcur_next(WT_CURSOR_BTREE *cbt, bool truncating) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_btcur_prev(WT_CURSOR_BTREE *cbt, bool truncating) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); -extern bool __wt_cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp); +extern int __wt_cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp, bool *valid) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_btcur_reset(WT_CURSOR_BTREE *cbt) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_btcur_search(WT_CURSOR_BTREE *cbt) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); extern int __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp) WT_GCC_FUNC_DECL_ATTRIBUTE((warn_unused_result)); diff --git a/src/third_party/wiredtiger/src/include/mutex.h b/src/third_party/wiredtiger/src/include/mutex.h index 2a3fc7448f8..ba32d166f03 100644 --- a/src/third_party/wiredtiger/src/include/mutex.h +++ b/src/third_party/wiredtiger/src/include/mutex.h @@ -44,9 +44,8 @@ struct __wt_rwlock { /* Read/write lock */ uint8_t current; /* Current ticket */ uint8_t next; /* Next available ticket */ uint8_t reader; /* Read queue ticket */ - uint8_t __notused; /* Padding */ - uint16_t readers_active;/* Count of active readers */ - uint16_t readers_queued;/* Count of queued readers */ + uint8_t readers_queued; /* Count of queued readers */ + uint32_t readers_active;/* Count of active readers */ } s; } u; diff --git a/src/third_party/wiredtiger/src/include/stat.h b/src/third_party/wiredtiger/src/include/stat.h index 7ef63cb0eaf..01a982b8602 100644 --- a/src/third_party/wiredtiger/src/include/stat.h +++ b/src/third_party/wiredtiger/src/include/stat.h @@ -627,6 +627,9 @@ struct __wt_connection_stats { int64_t txn_read_queue_head; int64_t txn_read_queue_inserts; int64_t txn_read_queue_len; + int64_t txn_rollback_to_stable; + int64_t txn_rollback_upd_aborted; + int64_t txn_rollback_las_removed; int64_t txn_set_ts; int64_t txn_set_ts_commit; int64_t txn_set_ts_commit_upd; diff --git a/src/third_party/wiredtiger/src/include/txn.h b/src/third_party/wiredtiger/src/include/txn.h index dd7f5d4a8bc..19e0be2d695 100644 --- a/src/third_party/wiredtiger/src/include/txn.h +++ b/src/third_party/wiredtiger/src/include/txn.h @@ -102,6 +102,7 @@ struct __wt_txn_global { volatile uint64_t oldest_id; WT_DECL_TIMESTAMP(commit_timestamp) + WT_DECL_TIMESTAMP(last_ckpt_timestamp) WT_DECL_TIMESTAMP(oldest_timestamp) WT_DECL_TIMESTAMP(pinned_timestamp) WT_DECL_TIMESTAMP(recovery_timestamp) diff --git a/src/third_party/wiredtiger/src/include/txn.i b/src/third_party/wiredtiger/src/include/txn.i index 5fcf8ee11c9..36cac1a26f3 100644 --- a/src/third_party/wiredtiger/src/include/txn.i +++ b/src/third_party/wiredtiger/src/include/txn.i @@ -9,6 +9,11 @@ static inline int __wt_txn_id_check(WT_SESSION_IMPL *session); static inline void __wt_txn_read_last(WT_SESSION_IMPL *session); +typedef enum { + WT_VISIBLE_FALSE=0, /* Not a visible update */ + WT_VISIBLE_PREPARE=1, /* Prepared update */ + WT_VISIBLE_TRUE=2 /* A visible update */ +} WT_VISIBLE_TYPE; #ifdef HAVE_TIMESTAMPS /* * __wt_txn_timestamp_flags -- @@ -539,33 +544,74 @@ __wt_txn_visible( } /* + * __wt_txn_upd_visible_type -- + * Visible type of given update for the current transaction. + */ +static inline WT_VISIBLE_TYPE +__wt_txn_upd_visible_type(WT_SESSION_IMPL *session, WT_UPDATE *upd) +{ + uint8_t upd_state; + bool upd_visible; + + for (;;__wt_yield()) { + /* Commit is in progress, yield and try again. */ + if ((upd_state = upd->state) == WT_UPDATE_STATE_LOCKED) + continue; + + upd_visible = __wt_txn_visible( + session, upd->txnid, WT_TIMESTAMP_NULL(&upd->timestamp)); + + /* + * The visibility check is only valid if the update does not + * change state. If the state does change, recheck visibility. + */ + if (upd->state == upd_state) + break; + } + + if (!upd_visible) + return (WT_VISIBLE_FALSE); + + if (upd_state == WT_UPDATE_STATE_PREPARED) + return (F_ISSET(&session->txn, WT_TXN_IGNORE_PREPARE) ? + WT_VISIBLE_FALSE : WT_VISIBLE_PREPARE); + + return (WT_VISIBLE_TRUE); +} + +/* * __wt_txn_upd_visible -- * Can the current transaction see the given update. */ static inline bool __wt_txn_upd_visible(WT_SESSION_IMPL *session, WT_UPDATE *upd) { - return (__wt_txn_visible(session, - upd->txnid, WT_TIMESTAMP_NULL(&upd->timestamp))); + return (__wt_txn_upd_visible_type(session, upd) == WT_VISIBLE_TRUE); } /* * __wt_txn_read -- * Get the first visible update in a list (or NULL if none are visible). */ -static inline WT_UPDATE * -__wt_txn_read(WT_SESSION_IMPL *session, WT_UPDATE *upd) +static inline int +__wt_txn_read(WT_SESSION_IMPL *session, WT_UPDATE *upd, WT_UPDATE **updp) { static WT_UPDATE tombstone = { .txnid = WT_TXN_NONE, .type = WT_UPDATE_TOMBSTONE }; + WT_VISIBLE_TYPE upd_visible; bool skipped_birthmark; + *updp = NULL; for (skipped_birthmark = false; upd != NULL; upd = upd->next) { /* Skip reserved place-holders, they're never visible. */ - if (upd->type != WT_UPDATE_RESERVE && - __wt_txn_upd_visible(session, upd)) - break; + if (upd->type != WT_UPDATE_RESERVE) { + upd_visible = __wt_txn_upd_visible_type(session, upd); + if (upd_visible == WT_VISIBLE_TRUE) + break; + if (upd_visible == WT_VISIBLE_PREPARE) + return (WT_PREPARE_CONFLICT); + } /* An invisible birthmark is equivalent to a tombstone. */ if (upd->type == WT_UPDATE_BIRTHMARK) skipped_birthmark = true; @@ -574,7 +620,8 @@ __wt_txn_read(WT_SESSION_IMPL *session, WT_UPDATE *upd) if (upd == NULL && skipped_birthmark) upd = &tombstone; - return (upd == NULL || upd->type == WT_UPDATE_BIRTHMARK ? NULL : upd); + *updp = (upd == NULL || upd->type == WT_UPDATE_BIRTHMARK ? NULL : upd); + return (0); } /* @@ -786,21 +833,32 @@ static inline int __wt_txn_update_check(WT_SESSION_IMPL *session, WT_UPDATE *upd) { WT_TXN *txn; + bool ignore_prepare_set; txn = &session->txn; - if (txn->isolation == WT_ISO_SNAPSHOT) - while (upd != NULL && !__wt_txn_upd_visible(session, upd)) { - if (upd->txnid != WT_TXN_ABORTED) { - WT_STAT_CONN_INCR( - session, txn_update_conflict); - WT_STAT_DATA_INCR( - session, txn_update_conflict); - return (__wt_txn_rollback_required(session, + if (txn->isolation != WT_ISO_SNAPSHOT) + return (0); + + /* + * Clear the ignore prepare setting of txn, as it is not supposed, to + * affect the visibility for update operations. + */ + ignore_prepare_set = F_ISSET(txn, WT_TXN_IGNORE_PREPARE); + F_CLR(txn, WT_TXN_IGNORE_PREPARE); + for (;upd != NULL && !__wt_txn_upd_visible(session, upd); + upd = upd->next) { + if (upd->txnid != WT_TXN_ABORTED) { + if (ignore_prepare_set) + F_SET(txn, WT_TXN_IGNORE_PREPARE); + WT_STAT_CONN_INCR(session, txn_update_conflict); + WT_STAT_DATA_INCR(session, txn_update_conflict); + return (__wt_txn_rollback_required(session, "conflict between concurrent operations")); - } - upd = upd->next; } + } + if (ignore_prepare_set) + F_SET(txn, WT_TXN_IGNORE_PREPARE); return (0); } diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in index a75c22497ce..1f2a438b8e9 100644 --- a/src/third_party/wiredtiger/src/include/wiredtiger.in +++ b/src/third_party/wiredtiger/src/include/wiredtiger.in @@ -2431,8 +2431,9 @@ struct __wt_connection { * timestamps of all active readers\, and \c stable returns the most * recent \c stable_timestamp set with WT_CONNECTION::set_timestamp. * See @ref transaction_timestamps., a string\, chosen from the - * following options: \c "all_committed"\, \c "oldest"\, \c "pinned"\, - * \c "recovery"\, \c "stable"; default \c all_committed.} + * following options: \c "all_committed"\, \c "last_checkpoint"\, \c + * "oldest"\, \c "pinned"\, \c "recovery"\, \c "stable"; default \c + * all_committed.} * @configend * @errors * If there is no matching timestamp (e.g., if this method is called @@ -5562,81 +5563,87 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_CONN_TXN_READ_QUEUE_INSERTS 1312 /*! transaction: read timestamp queue length */ #define WT_STAT_CONN_TXN_READ_QUEUE_LEN 1313 +/*! transaction: rollback to stable calls */ +#define WT_STAT_CONN_TXN_ROLLBACK_TO_STABLE 1314 +/*! transaction: rollback to stable updates aborted */ +#define WT_STAT_CONN_TXN_ROLLBACK_UPD_ABORTED 1315 +/*! transaction: rollback to stable updates removed from lookaside */ +#define WT_STAT_CONN_TXN_ROLLBACK_LAS_REMOVED 1316 /*! transaction: set timestamp calls */ -#define WT_STAT_CONN_TXN_SET_TS 1314 +#define WT_STAT_CONN_TXN_SET_TS 1317 /*! transaction: set timestamp commit calls */ -#define WT_STAT_CONN_TXN_SET_TS_COMMIT 1315 +#define WT_STAT_CONN_TXN_SET_TS_COMMIT 1318 /*! transaction: set timestamp commit updates */ -#define WT_STAT_CONN_TXN_SET_TS_COMMIT_UPD 1316 +#define WT_STAT_CONN_TXN_SET_TS_COMMIT_UPD 1319 /*! transaction: set timestamp oldest calls */ -#define WT_STAT_CONN_TXN_SET_TS_OLDEST 1317 +#define WT_STAT_CONN_TXN_SET_TS_OLDEST 1320 /*! transaction: set timestamp oldest updates */ -#define WT_STAT_CONN_TXN_SET_TS_OLDEST_UPD 1318 +#define WT_STAT_CONN_TXN_SET_TS_OLDEST_UPD 1321 /*! transaction: set timestamp stable calls */ -#define WT_STAT_CONN_TXN_SET_TS_STABLE 1319 +#define WT_STAT_CONN_TXN_SET_TS_STABLE 1322 /*! transaction: set timestamp stable updates */ -#define WT_STAT_CONN_TXN_SET_TS_STABLE_UPD 1320 +#define WT_STAT_CONN_TXN_SET_TS_STABLE_UPD 1323 /*! transaction: transaction begins */ -#define WT_STAT_CONN_TXN_BEGIN 1321 +#define WT_STAT_CONN_TXN_BEGIN 1324 /*! transaction: transaction checkpoint currently running */ -#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1322 +#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1325 /*! transaction: transaction checkpoint generation */ -#define WT_STAT_CONN_TXN_CHECKPOINT_GENERATION 1323 +#define WT_STAT_CONN_TXN_CHECKPOINT_GENERATION 1326 /*! transaction: transaction checkpoint max time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1324 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1327 /*! transaction: transaction checkpoint min time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1325 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1328 /*! transaction: transaction checkpoint most recent time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1326 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1329 /*! transaction: transaction checkpoint scrub dirty target */ -#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TARGET 1327 +#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TARGET 1330 /*! transaction: transaction checkpoint scrub time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TIME 1328 +#define WT_STAT_CONN_TXN_CHECKPOINT_SCRUB_TIME 1331 /*! transaction: transaction checkpoint total time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1329 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1332 /*! transaction: transaction checkpoints */ -#define WT_STAT_CONN_TXN_CHECKPOINT 1330 +#define WT_STAT_CONN_TXN_CHECKPOINT 1333 /*! * transaction: transaction checkpoints skipped because database was * clean */ -#define WT_STAT_CONN_TXN_CHECKPOINT_SKIPPED 1331 +#define WT_STAT_CONN_TXN_CHECKPOINT_SKIPPED 1334 /*! transaction: transaction failures due to cache overflow */ -#define WT_STAT_CONN_TXN_FAIL_CACHE 1332 +#define WT_STAT_CONN_TXN_FAIL_CACHE 1335 /*! * transaction: transaction fsync calls for checkpoint after allocating * the transaction ID */ -#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST 1333 +#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST 1336 /*! * transaction: transaction fsync duration for checkpoint after * allocating the transaction ID (usecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST_DURATION 1334 +#define WT_STAT_CONN_TXN_CHECKPOINT_FSYNC_POST_DURATION 1337 /*! transaction: transaction range of IDs currently pinned */ -#define WT_STAT_CONN_TXN_PINNED_RANGE 1335 +#define WT_STAT_CONN_TXN_PINNED_RANGE 1338 /*! transaction: transaction range of IDs currently pinned by a checkpoint */ -#define WT_STAT_CONN_TXN_PINNED_CHECKPOINT_RANGE 1336 +#define WT_STAT_CONN_TXN_PINNED_CHECKPOINT_RANGE 1339 /*! * transaction: transaction range of IDs currently pinned by named * snapshots */ -#define WT_STAT_CONN_TXN_PINNED_SNAPSHOT_RANGE 1337 +#define WT_STAT_CONN_TXN_PINNED_SNAPSHOT_RANGE 1340 /*! transaction: transaction range of timestamps currently pinned */ -#define WT_STAT_CONN_TXN_PINNED_TIMESTAMP 1338 +#define WT_STAT_CONN_TXN_PINNED_TIMESTAMP 1341 /*! * transaction: transaction range of timestamps pinned by the oldest * timestamp */ -#define WT_STAT_CONN_TXN_PINNED_TIMESTAMP_OLDEST 1339 +#define WT_STAT_CONN_TXN_PINNED_TIMESTAMP_OLDEST 1342 /*! transaction: transaction sync calls */ -#define WT_STAT_CONN_TXN_SYNC 1340 +#define WT_STAT_CONN_TXN_SYNC 1343 /*! transaction: transactions committed */ -#define WT_STAT_CONN_TXN_COMMIT 1341 +#define WT_STAT_CONN_TXN_COMMIT 1344 /*! transaction: transactions rolled back */ -#define WT_STAT_CONN_TXN_ROLLBACK 1342 +#define WT_STAT_CONN_TXN_ROLLBACK 1345 /*! transaction: update conflicts */ -#define WT_STAT_CONN_TXN_UPDATE_CONFLICT 1343 +#define WT_STAT_CONN_TXN_UPDATE_CONFLICT 1346 /*! * @} |