diff --git a/src/OpaqueVal.cc b/src/OpaqueVal.cc index 0b300cb02b..553c52d654 100644 --- a/src/OpaqueVal.cc +++ b/src/OpaqueVal.cc @@ -759,7 +759,9 @@ ValPtr BloomFilterVal::DoClone(CloneState* state) { if ( bloom_filter ) { auto bf = make_intrusive(bloom_filter->Clone()); assert(type); - bf->Typify(type); + if ( ! bf->Typify(type) ) + reporter->InternalError("Failed to typify new bloom_filter clone, clone already had valid type"); + return state->NewClone(this, std::move(bf)); } diff --git a/src/storage/backend/sqlite/SQLite.cc b/src/storage/backend/sqlite/SQLite.cc index cfc449c682..331381e5c7 100644 --- a/src/storage/backend/sqlite/SQLite.cc +++ b/src/storage/backend/sqlite/SQLite.cc @@ -496,7 +496,10 @@ void SQLite::DoExpire(double current_network_time) { // Automatically rollback the transaction when this object is deleted. auto deferred_rollback = util::Deferred([this]() { char* errMsg = nullptr; - sqlite3_exec(expire_db, "rollback transaction", nullptr, nullptr, &errMsg); + if ( int status = sqlite3_exec(expire_db, "rollback transaction", nullptr, nullptr, &errMsg); + status != SQLITE_OK ) + reporter->Warning("SQLite backend failed to rollback transaction during expiration: %s", errMsg); + sqlite3_free(errMsg); }); @@ -575,13 +578,21 @@ void SQLite::DoExpire(double current_network_time) { Error(err.c_str()); } - // Get the number of changes from the delete statement. This should be identical to the num_to_expire - // value earlier because we're under a transaction, but this should be the exact number that changed. + // Get the number of changes from the delete statement. This should be identical to + // the num_to_expire value earlier because we're under a transaction, but this should + // be the exact number that changed. int changes = sqlite3_changes(db); IncExpiredEntriesMetric(changes); - sqlite3_exec(expire_db, "commit transaction", nullptr, nullptr, &errMsg); + status = sqlite3_exec(expire_db, "commit transaction", nullptr, nullptr, &errMsg); + if ( status != SQLITE_OK ) + reporter->Warning("SQLite backend failed to commit transaction during expiration: %s", errMsg); + sqlite3_free(errMsg); + + // Don't try to rollback the transaction we just committed, since sqlite will just + // report an error. + deferred_rollback.Cancel(); } // returns true in case of error diff --git a/src/util-types.h b/src/util-types.h index 11f61b07b8..8e2e40bea4 100644 --- a/src/util-types.h +++ b/src/util-types.h @@ -68,7 +68,12 @@ private: class Deferred { public: Deferred(std::function deferred) : deferred(std::move(deferred)) {} - ~Deferred() { deferred(); } + ~Deferred() { + if ( deferred ) { + deferred(); + } + } + void Cancel() { deferred = nullptr; } private: std::function deferred;