mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-20 17:59:50 +00:00
when disk is full, make relay log and return errors but not crash
This commit is contained in:
@ -33,10 +33,25 @@ void RelayServer::runWriter(ThreadPool<MsgWriter>::Thread &thr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
try {
|
||||||
auto txn = env.txn_rw();
|
auto txn = env.txn_rw();
|
||||||
writeEvents(txn, newEvents);
|
writeEvents(txn, newEvents);
|
||||||
txn.commit();
|
txn.commit();
|
||||||
|
} catch (std::exception &e) {
|
||||||
|
LE << "Error writing " << newEvents.size() << " events: " << e.what();
|
||||||
|
|
||||||
|
for (auto &newEvent : newEvents) {
|
||||||
|
auto *flat = flatbuffers::GetRoot<NostrIndex::Event>(newEvent.flatStr.data());
|
||||||
|
auto eventIdHex = to_hex(sv(flat->id()));
|
||||||
|
MsgWriter::AddEvent *addEventMsg = static_cast<MsgWriter::AddEvent*>(newEvent.userData);
|
||||||
|
|
||||||
|
std::string message = "Write error: ";
|
||||||
|
message += e.what();
|
||||||
|
|
||||||
|
sendOKResponse(addEventMsg->connId, eventIdHex, false, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log
|
// Log
|
||||||
|
Reference in New Issue
Block a user