void PersistentSBF::remove_tmp_files(const filesystem::path& path, std::lock_guard<std::mutex>& /* lock */)
{
Regex file_regex(d_prefix + ".*\\." + bf_suffix + "\\..{8}$");
- for (const auto& file : filesystem::directory_iterator (path)) {
+ for (const auto& file : filesystem::directory_iterator(path)) {
if (filesystem::is_regular_file(file.path()) && file_regex.match(file.path().filename().string())) {
filesystem::remove(file);
}
filesystem::path newest_file;
std::time_t newest_time = 0;
Regex file_regex(d_prefix + ".*\\." + bf_suffix + "$");
- for (const auto& file : filesystem::directory_iterator (path)) {
+ for (const auto& file : filesystem::directory_iterator(path)) {
if (filesystem::is_regular_file(file.path()) && file_regex.match(file.path().filename().string())) {
if (ignore_pid || (file.path().filename().string().find(std::to_string(getpid())) == std::string::npos)) {
// look for the newest file matching the regex
- if (last_write_time(file.path()) > newest_time) {
+ if (last_write_time(file.path()) > newest_time) {
newest_time = last_write_time(file.path());
newest_file = file.path();
}
bool NODDB::isNewDomain(const DNSName& dname)
{
std::string dname_lc = dname.toDNSStringLC();
- // The only time this should block is when snapshotting from the
- // housekeeping thread
// the result is always the inverse of what is returned by the SBF
return !d_psbf.testAndAdd(dname_lc);
}
const float c_fp_rate = 0.01;
const size_t c_num_cells = 67108864;
const uint8_t c_num_dec = 10;
- const unsigned int snapshot_interval_default = 30; // XXX 600;
+const unsigned int snapshot_interval_default = 600;
const std::string bf_suffix = "bf";
const std::string sbf_prefix = "sbf";
log->info(Logr::Error, "Could not initialize domain tracking"));
_exit(1);
}
- std::thread thread([tid = std::this_thread::get_id()]() {
- g_nodDBp->housekeepingThread(tid);
- });
- thread.detach();
+ if (::arg().asNum("new-domain-db-snapshot-interval") > 0) {
+ g_nodDBp->setSnapshotInterval(::arg().asNum("new-domain-db-snapshot-interval"));
+ std::thread thread([tid = std::this_thread::get_id()]() {
+ g_nodDBp->housekeepingThread(tid);
+ });
+ thread.detach();
+ }
}
if (g_udrEnabled) {
uint32_t num_cells = ::arg().asNum("unique-response-db-size");
log->info(Logr::Error, "Could not initialize unique response tracking"));
_exit(1);
}
- std::thread thread([tid = std::this_thread::get_id()]() {
- g_udrDBp->housekeepingThread(tid);
- });
- thread.detach();
+ if (::arg().asNum("new-domain-db-snapshot-interval") > 0) {
+ g_udrDBp->setSnapshotInterval(::arg().asNum("new-domain-db-snapshot-interval"));
+ std::thread thread([tid = std::this_thread::get_id()]() {
+ g_udrDBp->housekeepingThread(tid);
+ });
+ thread.detach();
+ }
}
}
''',
'versionadded': '4.2.0'
},
+ {
+ 'name' : 'db_snapshot_interval',
+ 'section' : 'nod',
+ 'oldname' : 'new-domain-db-snapshot-interval',
+ 'type' : LType.Uint64,
+ 'default' : '600',
+ 'help' : 'Interval (in seconds) to write the NOD and UDR DB snapshots',
+ 'doc' : '''
+Interval (in seconds) to write the NOD and UDR DB snapshots.
+Set to zero to disable snapshot writing.',
+ ''',
+ 'versionadded': '5.1.0'
+ },
{
'name' : 'whitelist',
'section' : 'nod',
#include <boost/dynamic_bitset.hpp>
#include "misc.hh"
#include "noinitvector.hh"
-#include "views.hh"
#include "ext/probds/murmur3.h"
namespace bf