summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/leveldb/leveldb_wt.cc6
-rw-r--r--dist/api_data.py10
-rw-r--r--dist/s_define.list1
-rwxr-xr-xdist/s_style5
-rw-r--r--examples/c/ex_all.c2
-rw-r--r--examples/java/com/wiredtiger/examples/ex_all.java2
-rw-r--r--ext/datasources/helium/helium.c2
-rw-r--r--src/btree/bt_evict.c2
-rw-r--r--src/conn/api_strerror.c4
-rw-r--r--src/docs/cursor-ops.dox2
-rw-r--r--src/docs/error-handling.dox8
-rw-r--r--src/docs/transactions.dox8
-rw-r--r--src/docs/upgrading.dox11
-rw-r--r--src/include/api.h2
-rw-r--r--src/include/txn.i2
-rw-r--r--src/include/wiredtiger.in30
-rw-r--r--test/checkpoint/workers.c6
-rw-r--r--test/format/compact.c2
-rw-r--r--test/format/ops.c32
19 files changed, 79 insertions, 58 deletions
diff --git a/api/leveldb/leveldb_wt.cc b/api/leveldb/leveldb_wt.cc
index 6425a5a8dfd..8fc7d1ca092 100644
--- a/api/leveldb/leveldb_wt.cc
+++ b/api/leveldb/leveldb_wt.cc
@@ -93,8 +93,6 @@ Status WiredTigerErrorToStatus(int wiredTigerError, const char *msg) {
return Status::NotFound(Slice(msg));
else if (wiredTigerError == WT_ERROR || wiredTigerError == WT_PANIC)
return Status::Corruption(Slice(msg));
- else if (wiredTigerError == WT_DEADLOCK)
- return Status::IOError("DEADLOCK"); // TODO: Is this the best translation?
else if (wiredTigerError == ENOTSUP)
return Status::NotSupported(Slice(msg));
else if (wiredTigerError == EINVAL)
@@ -103,6 +101,8 @@ Status WiredTigerErrorToStatus(int wiredTigerError, const char *msg) {
wiredTigerError == EIO || wiredTigerError == EBADF ||
wiredTigerError == EEXIST || wiredTigerError == ENOSPC)
return Status::IOError(Slice(msg));
+ else if (wiredTigerError == WT_ROLLBACK)
+ return Status::IOError("ROLLBACK"); // TODO: Is this the best translation?
else
return Status::Corruption(Slice(msg));
}
@@ -395,7 +395,7 @@ DbImpl::Write(const WriteOptions& options, WriteBatch* updates)
throw;
}
#endif
- if (!status.ok() || (ret = handler.GetWiredTigerStatus()) != WT_DEADLOCK)
+ if (!status.ok() || (ret = handler.GetWiredTigerStatus()) != WT_ROLLBACK)
break;
// Roll back the transaction on deadlock so we can try again
if (need_txn && (ret = session->rollback_transaction(session, NULL)) != 0) {
diff --git a/dist/api_data.py b/dist/api_data.py
index d133c8a082c..4cfa126f2fa 100644
--- a/dist/api_data.py
+++ b/dist/api_data.py
@@ -8,11 +8,6 @@ class Error:
self.flags = flags
errors = [
- Error('WT_DEADLOCK', 'conflict between concurrent operations', '''
- This error is generated when an operation cannot be completed
- due to a conflict with concurrent operations. The operation
- may be retried; if a transaction is in progress, it should be
- rolled back and the operation retried in a new transaction.'''),
Error('WT_DUPLICATE_KEY', 'attempt to insert an existing key', '''
This error is generated when the application attempts to insert
a record with the same key as an existing record without the
@@ -29,6 +24,11 @@ errors = [
This error indicates an underlying problem that requires the
application exit and restart.'''),
Error('WT_RESTART', 'restart the operation (internal)', undoc=True),
+ Error('WT_ROLLBACK', 'conflict between concurrent operations', '''
+ This error is generated when an operation cannot be completed
+ due to a conflict with concurrent operations. The operation
+ may be retried; if a transaction is in progress, it should be
+ rolled back and the operation retried in a new transaction.'''),
]
class Method:
diff --git a/dist/s_define.list b/dist/s_define.list
index 3bae650c013..618c31d2d7a 100644
--- a/dist/s_define.list
+++ b/dist/s_define.list
@@ -37,6 +37,7 @@ WT_ATOMIC_SUB2
WT_BARRIER
WT_BLOCK_DESC_SIZE
WT_CACHE_LINE_ALIGNMENT
+WT_DEADLOCK
WT_DEBUG_BYTE
WT_HANDLE_CLOSED
WT_HANDLE_NULLABLE
diff --git a/dist/s_style b/dist/s_style
index 8afde0aba6e..e36924dffb9 100755
--- a/dist/s_style
+++ b/dist/s_style
@@ -59,6 +59,11 @@ for f in \
cat $t
fi
+ if grep WT_DEADLOCK $f | grep -v '#define.WT_DEADLOCK' > $t; then
+ echo "$f: WT_DEADLOCK deprecated in favor of WT_ROLLBACK"
+ cat $t
+ fi
+
if ! expr "$f" : 'examples/c/.*' > /dev/null &&
! expr "$f" : 'ext/datasources/helium/helium.c' > /dev/null &&
! expr "$f" : 'src/include/os.h' > /dev/null &&
diff --git a/examples/c/ex_all.c b/examples/c/ex_all.c
index d4f571ccaf6..c979c7b7cea 100644
--- a/examples/c/ex_all.c
+++ b/examples/c/ex_all.c
@@ -703,7 +703,7 @@ transaction_ops(WT_CONNECTION *conn, WT_SESSION *session)
* and all cursors are reset.
*/
break;
- case WT_DEADLOCK: /* Update conflict */
+ case WT_ROLLBACK: /* Update conflict */
default: /* Other error */
ret = session->rollback_transaction(session, NULL);
/* The rollback_transaction call resets all cursors. */
diff --git a/examples/java/com/wiredtiger/examples/ex_all.java b/examples/java/com/wiredtiger/examples/ex_all.java
index a0a2e2cdc6a..8648d95a185 100644
--- a/examples/java/com/wiredtiger/examples/ex_all.java
+++ b/examples/java/com/wiredtiger/examples/ex_all.java
@@ -666,7 +666,7 @@ transaction_ops(Connection conn, Session session)
* If commit_transaction fails, the transaction was rolled-back.
*/
break;
- case wiredtiger.WT_DEADLOCK: /* Update conflict */
+ case wiredtiger.WT_ROLLBACK: /* Update conflict */
default: /* Other error */
ret = session.rollback_transaction(null);
/* The rollback_transaction call resets all open cursors. */
diff --git a/ext/datasources/helium/helium.c b/ext/datasources/helium/helium.c
index 2c1b5891fa1..f5be26e9119 100644
--- a/ext/datasources/helium/helium.c
+++ b/ext/datasources/helium/helium.c
@@ -806,7 +806,7 @@ cache_value_update_check(WT_CURSOR *wtcursor)
for (i = 0, cp = cursor->cache; i < cursor->cache_entries; ++i, ++cp)
if (!cache_value_aborted(wtcursor, cp) &&
!wtext->transaction_visible(wtext, session, cp->txnid))
- return (WT_DEADLOCK);
+ return (WT_ROLLBACK);
return (0);
}
diff --git a/src/btree/bt_evict.c b/src/btree/bt_evict.c
index 2d192309c8a..ff049553c7f 100644
--- a/src/btree/bt_evict.c
+++ b/src/btree/bt_evict.c
@@ -1118,7 +1118,7 @@ __evict_get_ref(
__wt_txn_am_oldest(session)) {
F_CLR(cache, WT_EVICT_STUCK);
WT_STAT_FAST_CONN_INCR(session, txn_fail_cache);
- return (WT_DEADLOCK);
+ return (WT_ROLLBACK);
}
/*
diff --git a/src/conn/api_strerror.c b/src/conn/api_strerror.c
index 8cd410d4f01..1ad136eae12 100644
--- a/src/conn/api_strerror.c
+++ b/src/conn/api_strerror.c
@@ -16,8 +16,6 @@ wiredtiger_strerror(int error)
return ("Successful return: 0");
switch (error) {
- case WT_DEADLOCK:
- return ("WT_DEADLOCK: conflict between concurrent operations");
case WT_DUPLICATE_KEY:
return ("WT_DUPLICATE_KEY: attempt to insert an existing key");
case WT_ERROR:
@@ -28,6 +26,8 @@ wiredtiger_strerror(int error)
return ("WT_PANIC: WiredTiger library panic");
case WT_RESTART:
return ("WT_RESTART: restart the operation (internal)");
+ case WT_ROLLBACK:
+ return ("WT_ROLLBACK: conflict between concurrent operations");
default:
if (error > 0 && (p = strerror(error)) != NULL)
return (p);
diff --git a/src/docs/cursor-ops.dox b/src/docs/cursor-ops.dox
index d9d8f19868c..e4832267f08 100644
--- a/src/docs/cursor-ops.dox
+++ b/src/docs/cursor-ops.dox
@@ -126,7 +126,7 @@ the cursor. These operations are WT_CURSOR::remove, WT_CURSOR::search,
WT_CURSOR::search_near and WT_CURSOR::update, but <b>do not include</b>
WT_CURSOR::insert, as it does not position the cursor.
-If such an operation fails (for example, due to a ::WT_DEADLOCK error),
+If such an operation fails (for example, due to a ::WT_ROLLBACK error),
it may be retried without calling WT_CURSOR::set_key or
WT_CURSOR::set_value again. That is, the cursor may still reference the
application-supplied memory until it is successfully positioned.
diff --git a/src/docs/error-handling.dox b/src/docs/error-handling.dox
index 0b4ac778639..ea8b721bd7d 100644
--- a/src/docs/error-handling.dox
+++ b/src/docs/error-handling.dox
@@ -4,7 +4,7 @@ WiredTiger operations return a value of 0 on success and a non-zero
value on error. Error codes may be either positive or negative:
positive error codes are standard error codes as described for
POSIX-like systems (for example, EINVAL or EBUSY), negative error codes
-are WiredTiger-specific (for example, WT_DEADLOCK).
+are WiredTiger-specific (for example, WT_ROLLBACK).
WiredTiger-specific error codes always appear in the -31,800 to -31,999
range.
@@ -25,9 +25,6 @@ The following is a list of possible WiredTiger-specific errors:
@if IGNORE_BUILT_BY_API_ERR_BEGIN
@endif
-@par <code>WT_DEADLOCK</code>
-This error is generated when an operation cannot be completed due to a conflict with concurrent operations. The operation may be retried; if a transaction is in progress, it should be rolled back and the operation retried in a new transaction.
-
@par <code>WT_DUPLICATE_KEY</code>
This error is generated when the application attempts to insert a record with the same key as an existing record without the 'overwrite' configuration to WT_SESSION::open_cursor.
@@ -40,6 +37,9 @@ This error indicates an operation did not find a value to return. This includes
@par <code>WT_PANIC</code>
This error indicates an underlying problem that requires the application exit and restart.
+@par <code>WT_ROLLBACK</code>
+This error is generated when an operation cannot be completed due to a conflict with concurrent operations. The operation may be retried; if a transaction is in progress, it should be rolled back and the operation retried in a new transaction.
+
@if IGNORE_BUILT_BY_API_ERR_END
@endif
diff --git a/src/docs/transactions.dox b/src/docs/transactions.dox
index 7f3acaa245d..8b57152cf52 100644
--- a/src/docs/transactions.dox
+++ b/src/docs/transactions.dox
@@ -42,7 +42,7 @@ If WT_SESSION::commit_transaction returns an error for any reason, the
transaction was rolled back, not committed.
When transactions are used, data operations can encounter a conflict and
-fail with the ::WT_DEADLOCK error. If this error occurs, transactions
+fail with the ::WT_ROLLBACK error. If this error occurs, transactions
should be rolled back with WT_SESSION::rollback_transaction and the
operation retried.
@@ -76,14 +76,14 @@ the bottleneck of a centralized lock manager and ensures transactional
operations do not block: reads do not block writes, and vice versa.
Further, writes do not block writes, although concurrent transactions
-updating the same value will fail with ::WT_DEADLOCK. Some applications
+updating the same value will fail with ::WT_ROLLBACK. Some applications
may benefit from application-level synchronization to avoid repeated
attempts to rollback and update the same value.
-Operations in transactions may also fail with the ::WT_DEADLOCK error if
+Operations in transactions may also fail with the ::WT_ROLLBACK error if
some resource cannot be allocated after repeated attempts. For example, if
the cache is not large enough to hold the updates required to satisfy
-transactional readers, an operation may fail and return ::WT_DEADLOCK.
+transactional readers, an operation may fail and return ::WT_ROLLBACK.
@section transaction_isolation Isolation levels
diff --git a/src/docs/upgrading.dox b/src/docs/upgrading.dox
index 71b666abdec..d9346faa170 100644
--- a/src/docs/upgrading.dox
+++ b/src/docs/upgrading.dox
@@ -1,5 +1,16 @@
/*! @page upgrading Upgrading WiredTiger applications
+@section version_241 Upgrading to Version 2.4.1
+
+<dl>
+<dt>WT_DEADLOCK renamed</dt>
+<dd>
+The \c WT_DEADLOCK error return has been deprecated in favor of ::WT_ROLLBACK
+to clarify that WT_SESSION::rollback_transaction should be called; no program
+changes are required.
+</dd>
+</dl>
+
@section version_240 Upgrading to Version 2.4.0
<dl>
diff --git a/src/include/api.h b/src/include/api.h
index ec74138bdd1..d6e923e3560 100644
--- a/src/include/api.h
+++ b/src/include/api.h
@@ -66,7 +66,7 @@
ret = __wt_txn_commit((s), NULL); \
else { \
WT_TRET(__wt_txn_rollback((s), NULL)); \
- if ((ret == 0 || ret == WT_DEADLOCK) && \
+ if ((ret == 0 || ret == WT_ROLLBACK) && \
(retry)) { \
ret = 0; \
continue; \
diff --git a/src/include/txn.i b/src/include/txn.i
index 8bdc0c6bd21..9a8d64034c0 100644
--- a/src/include/txn.i
+++ b/src/include/txn.i
@@ -284,7 +284,7 @@ __wt_txn_update_check(WT_SESSION_IMPL *session, WT_UPDATE *upd)
if (upd->txnid != WT_TXN_ABORTED) {
WT_STAT_FAST_DATA_INCR(
session, txn_update_conflict);
- return (WT_DEADLOCK);
+ return (WT_ROLLBACK);
}
upd = upd->next;
}
diff --git a/src/include/wiredtiger.in b/src/include/wiredtiger.in
index de4a04f1d66..d42d327ba0b 100644
--- a/src/include/wiredtiger.in
+++ b/src/include/wiredtiger.in
@@ -2456,49 +2456,53 @@ const char *wiredtiger_version(int *majorp, int *minorp, int *patchp);
* Error return section: BEGIN
*/
/*!
- * Conflict between concurrent operations.
- * This error is generated when an operation cannot be completed due to a
- * conflict with concurrent operations. The operation may be retried; if a
- * transaction is in progress, it should be rolled back and the operation
- * retried in a new transaction.
- */
-#define WT_DEADLOCK -31800
-/*!
* Attempt to insert an existing key.
* This error is generated when the application attempts to insert a record with
* the same key as an existing record without the 'overwrite' configuration to
* WT_SESSION::open_cursor.
*/
-#define WT_DUPLICATE_KEY -31801
+#define WT_DUPLICATE_KEY -31800
/*!
* Non-specific WiredTiger error.
* This error is returned when an error is not covered by a specific error
* return.
*/
-#define WT_ERROR -31802
+#define WT_ERROR -31801
/*!
* Item not found.
* This error indicates an operation did not find a value to return. This
* includes cursor search and other operations where no record matched the
* cursor's search key such as WT_CURSOR::update or WT_CURSOR::remove.
*/
-#define WT_NOTFOUND -31803
+#define WT_NOTFOUND -31802
/*!
* WiredTiger library panic.
* This error indicates an underlying problem that requires the application exit
* and restart.
*/
-#define WT_PANIC -31804
+#define WT_PANIC -31803
/*! @cond internal */
/*! Restart the operation (internal). */
-#define WT_RESTART -31805
+#define WT_RESTART -31804
/*! @endcond */
+/*!
+ * Conflict between concurrent operations.
+ * This error is generated when an operation cannot be completed due to a
+ * conflict with concurrent operations. The operation may be retried; if a
+ * transaction is in progress, it should be rolled back and the operation
+ * retried in a new transaction.
+ */
+#define WT_ROLLBACK -31805
/*
* Error return section: END
* DO NOT EDIT: automatically built by dist/api_err.py.
*/
/*! @} */
+#ifndef DOXYGEN
+#define WT_DEADLOCK WT_ROLLBACK /* Backward compatibility */
+#endif
+
/*! @} */
/*!
diff --git a/test/checkpoint/workers.c b/test/checkpoint/workers.c
index b7858cb8292..52f25a4b1d7 100644
--- a/test/checkpoint/workers.c
+++ b/test/checkpoint/workers.c
@@ -136,8 +136,8 @@ worker_op(WT_CURSOR *cursor, uint64_t keyno, u_int new_val)
valuebuf, sizeof(valuebuf), "%037u", new_val);
cursor->set_value(cursor, valuebuf);
if ((ret = cursor->insert(cursor)) != 0) {
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
return (log_print_err("cursor.insert", ret, 1));
}
return (0);
@@ -212,7 +212,7 @@ real_worker(void)
"real_worker:commit_transaction", ret, 1);
goto err;
}
- } else if (ret == WT_DEADLOCK) {
+ } else if (ret == WT_ROLLBACK) {
if ((ret = session->rollback_transaction(
session, NULL)) != 0) {
(void)log_print_err(
diff --git a/test/format/compact.c b/test/format/compact.c
index b1c392461af..3fbf6fca33a 100644
--- a/test/format/compact.c
+++ b/test/format/compact.c
@@ -64,7 +64,7 @@ compact(void *arg)
break;
if ((ret = session->compact(
- session, g.uri, NULL)) != 0 && ret != WT_DEADLOCK)
+ session, g.uri, NULL)) != 0 && ret != WT_ROLLBACK)
die(ret, "session.compact");
}
diff --git a/test/format/ops.c b/test/format/ops.c
index 274acfc6ae1..27f983fb295 100644
--- a/test/format/ops.c
+++ b/test/format/ops.c
@@ -592,8 +592,8 @@ read_row(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno)
ret = cursor->get_value(cursor, &value);
}
}
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "read_row: read row %" PRIu64, keyno);
/*
@@ -650,8 +650,8 @@ nextprev(WT_CURSOR *cursor, int next, int *notfoundp)
keyno = 0;
ret = next ? cursor->next(cursor) : cursor->prev(cursor);
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
if (ret == 0)
switch (g.type) {
case FIX:
@@ -760,8 +760,8 @@ row_update(
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
ret = cursor->update(cursor);
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "row_update: update row %" PRIu64 " by key", keyno);
@@ -807,8 +807,8 @@ col_update(WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t keyno)
else
cursor->set_value(cursor, value);
ret = cursor->update(cursor);
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "col_update: %" PRIu64, keyno);
@@ -952,8 +952,8 @@ row_insert(
cursor->set_key(cursor, key);
cursor->set_value(cursor, value);
ret = cursor->insert(cursor);
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "row_insert: insert row %" PRIu64 " by key", keyno);
@@ -985,8 +985,8 @@ col_insert(WT_CURSOR *cursor, WT_ITEM *key, WT_ITEM *value, uint64_t *keynop)
else
cursor->set_value(cursor, value);
if ((ret = cursor->insert(cursor)) != 0) {
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
die(ret, "cursor.insert");
}
if ((ret = cursor->get_key(cursor, &keyno)) != 0)
@@ -1039,8 +1039,8 @@ row_remove(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno, int *notfoundp)
/* We use the cursor in overwrite mode, check for existence. */
if ((ret = cursor->search(cursor)) == 0)
ret = cursor->remove(cursor);
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "row_remove: remove %" PRIu64 " by key", keyno);
*notfoundp = (ret == WT_NOTFOUND);
@@ -1074,8 +1074,8 @@ col_remove(WT_CURSOR *cursor, WT_ITEM *key, uint64_t keyno, int *notfoundp)
/* We use the cursor in overwrite mode, check for existence. */
if ((ret = cursor->search(cursor)) == 0)
ret = cursor->remove(cursor);
- if (ret == WT_DEADLOCK)
- return (WT_DEADLOCK);
+ if (ret == WT_ROLLBACK)
+ return (WT_ROLLBACK);
if (ret != 0 && ret != WT_NOTFOUND)
die(ret, "col_remove: remove %" PRIu64 " by key", keyno);
*notfoundp = (ret == WT_NOTFOUND);