The TDB1 code logs multiple times on errors; we must prevent that in
the limited case where locking fails. With TDB2, this can happen due
to the lock function attribute, where the user supplies replacement
locking functions which are allowed to return with errno EAGAIN or
EINTR for various special-effects. Flooding the logs for this is
unfriendly.
int ret;
ret = tdb1_lock_list(tdb, list, ltype, TDB_LOCK_WAIT);
int ret;
ret = tdb1_lock_list(tdb, list, ltype, TDB_LOCK_WAIT);
+ /* Don't log for EAGAIN and EINTR: they could have overridden lock fns */
+ if (ret && errno != EAGAIN && errno != EINTR) {
tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
"tdb1_lock failed on list %d "
"ltype=%d (%s)", list, ltype, strerror(errno));
tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
"tdb1_lock failed on list %d "
"ltype=%d (%s)", list, ltype, strerror(errno));
/* get a read lock from the freelist to the end of file. This
is upgraded to a write lock during the commit */
if (tdb1_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, true) == -1) {
/* get a read lock from the freelist to the end of file. This
is upgraded to a write lock during the commit */
if (tdb1_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, true) == -1) {
- tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
- "tdb1_transaction_start: failed to get hash locks");
+ if (errno != EAGAIN && errno != EINTR) {
+ tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
+ "tdb1_transaction_start:"
+ " failed to get hash locks");
+ }
goto fail_allrecord_lock;
}
goto fail_allrecord_lock;
}
/* upgrade the main transaction lock region to a write lock */
if (tdb1_allrecord_upgrade(tdb) == -1) {
/* upgrade the main transaction lock region to a write lock */
if (tdb1_allrecord_upgrade(tdb) == -1) {
- tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
- "tdb1_transaction_prepare_commit:"
- " failed to upgrade hash locks");
+ if (errno != EAGAIN && errno != EINTR) {
+ tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
+ "tdb1_transaction_prepare_commit:"
+ " failed to upgrade hash locks");
+ }
_tdb1_transaction_cancel(tdb);
return -1;
}
_tdb1_transaction_cancel(tdb);
return -1;
}
/* get the open lock - this prevents new users attaching to the database
during the commit */
if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) {
/* get the open lock - this prevents new users attaching to the database
during the commit */
if (tdb1_nest_lock(tdb, TDB1_OPEN_LOCK, F_WRLCK, TDB_LOCK_WAIT) == -1) {
- tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
- "tdb1_transaction_prepare_commit:"
- " failed to get open lock");
+ if (errno != EAGAIN && errno != EINTR) {
+ tdb_logerr(tdb, tdb->last_error, TDB_LOG_ERROR,
+ "tdb1_transaction_prepare_commit:"
+ " failed to get open lock");
+ }
_tdb1_transaction_cancel(tdb);
return -1;
}
_tdb1_transaction_cancel(tdb);
return -1;
}