No try/catch in alloc_engine.cc:reclaimExpiredLease
This fix will allow Kea to continue firing timer reclaim-expired-leases after
a DB restart. The original problem was due to not catching an exception in
function AllocEngine::reclaimExpiredLeases4. Note that for the similar timer
flush-reclaimed-leases exception handling is present in function
AllocEngine::deleteExpiredReclaimedLeases4.
I believe the basic issue was that Kea was connected to the DB and inserted
the lease then the connection to the DB was broken (DB stopped and restarted)
and the code in reclaimExpiredLeases4 didn't catch the exception.
The fix is to add a try/catch around the offending code and add a message for
this in the .mes file. The same issue probably exists in the reclaimExpiredLeases6
function as well.
#ifndef ORIGINAL_ISC_CODE
try {
#endif
// The value of 0 has a special meaning - reclaim all.
if (max_leases > 0) {
// If the value is non-zero, the caller has limited the number of
// leases to reclaim. We obtain one lease more to see if there will
// be still leases left after this pass.
lease_mgr.getExpiredLeases4(leases, max_leases + 1);
// There are more leases expired leases than we will process in this
// pass, so we should mark it as an incomplete reclamation. We also
// remove this extra lease (which we don't want to process anyway)
// from the collection.
if (leases.size() > max_leases) {
leases.pop_back();
incomplete_reclamation = true;
}
} else {
// If there is no limitation on the number of leases to reclaim,
// we will try to process all. Hence, we don't mark it as incomplete
// reclamation just yet.
lease_mgr.getExpiredLeases4(leases, max_leases);
}
#ifndef ORIGINAL_ISC_CODE
} catch (const std::exception& ex) {
LOG_ERROR(alloc_engine_logger, ALLOC_ENGINE_V4_LEASES_RECLAMATION_FAILED)
.arg(ex.what());
}
#endif