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_ROLLBACK
).
WiredTiger returns EBUSY
for operations requiring exclusive access, when an object is not available for exclusive access. These operations include the WT_SESSION::alter, WT_SESSION::drop, WT_SESSION::rename, WT_SESSION::salvage, WT_SESSION::upgrade and WT_SESSION::verify methods, all of which will return EBUSY
and fail if there are open cursors on the target object. Internal WiredTiger threads may temporarily open cursors on objects (for example, threads performing operations like statistics logging), and in that case operations may temporarily fail and return EBUSY
when there are no application cursors open on the object. In this case, simply retrying the operation should be sufficient.
Additionally, unwritten data in the WiredTiger cache will prevent exclusive access to objects. In this case, calling the WT_SESSION:checkpoint method to perform a database checkpoint should resolve the problem, allowing a subsequent retry of the operation requiring exclusive access to succeed. Further failures imply other threads of control simultaneously updating the object in cache. Repeatedly calling checkpoint will race with those threads, and it's unspecified when or even if exclusive access to the object will be granted. Generally, applications will not call WiredTiger methods requiring exclusive access when the objects might be in active use by other threads.
WiredTiger-specific error codes are allocated from -31,800 to -31,999, inclusive. The following is a list of the WiredTiger-specific return values:
WT_ROLLBACK
WT_DUPLICATE_KEY
WT_ERROR
WT_NOTFOUND
WT_PANIC
WT_RUN_RECOVERY
WT_CACHE_FULL
WT_PREPARE_CONFLICT
WT_TRY_SALVAGE
The WT_SESSION::strerror and wiredtiger_strerror functions return the standard text message associated with any WiredTiger, ISO C, or POSIX standard API.
Note that wiredtiger_strerror is not thread-safe.