mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 18:35:46 +02:00
fix(server): rdb loader catch bad alloc (#1748)
While loading rdb snapshot, if oom is reached a bad alloc exception is thrown. Now we catch it and write warning to log and fali loader. Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
parent
e020f8734b
commit
901d3fff58
1 changed files with 10 additions and 3 deletions
|
@ -2268,9 +2268,16 @@ void RdbLoader::LoadItemsBuffer(DbIndex db_ind, const ItemsBuf& ib) {
|
|||
if (item->expire_ms > 0 && db_cntx.time_now_ms >= item->expire_ms)
|
||||
continue;
|
||||
|
||||
auto [it, added] = db_slice.AddOrUpdate(db_cntx, item->key, std::move(pv), item->expire_ms);
|
||||
if (!added) {
|
||||
LOG(WARNING) << "RDB has duplicated key '" << item->key << "' in DB " << db_ind;
|
||||
try {
|
||||
auto [it, added] = db_slice.AddOrUpdate(db_cntx, item->key, std::move(pv), item->expire_ms);
|
||||
if (!added) {
|
||||
LOG(WARNING) << "RDB has duplicated key '" << item->key << "' in DB " << db_ind;
|
||||
}
|
||||
} catch (const std::bad_alloc&) {
|
||||
LOG(ERROR) << "OOM failed to add key '" << item->key << "' in DB " << db_ind;
|
||||
ec_ = RdbError(errc::out_of_memory);
|
||||
stop_early_ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue