#include <boost/iostreams/device/back_inserter.hpp>
+#ifdef HAVE_SYSTEMD
+#include <systemd/sd-daemon.h>
+#endif
+
#include <stdio.h>
#include <unistd.h>
throw std::runtime_error("mdb_txn_begin failed");
}
+#ifdef HAVE_SYSTEMD
+ /* A schema migration may take a long time. Extend the startup service timeout to 1 day,
+ * but only if this is beyond the original maximum time of TimeoutStartSec=.
+ */
+ sd_notify(0, "EXTEND_TIMEOUT_USEC=86400000000");
+#endif
+
std::cerr << "migrating shards" << std::endl;
for (uint32_t i = 0; i < shards; i++) {
string shardfile = filename + "-" + std::to_string(i);
d_asyncFlag = MDB_NOSYNC;
else if (syncMode == "nometasync")
d_asyncFlag = MDB_NOMETASYNC;
- else if (syncMode == "mapasync")
- d_asyncFlag = MDB_MAPASYNC;
else if (syncMode.empty() || syncMode == "sync")
d_asyncFlag = 0;
else
return ret;
}
-std::shared_ptr<LMDBBackend::RecordsROTransaction> LMDBBackend::getRecordsROTransaction(uint32_t id, std::shared_ptr<LMDBBackend::RecordsRWTransaction> rwtxn)
+std::shared_ptr<LMDBBackend::RecordsROTransaction> LMDBBackend::getRecordsROTransaction(uint32_t id, const std::shared_ptr<LMDBBackend::RecordsRWTransaction>& rwtxn)
{
auto& shard = d_trecords[id % s_shards];
if (!shard.env) {
return true;
}
-int LMDBBackend::genChangeDomain(const DNSName& domain, std::function<void(DomainInfo&)> func)
+int LMDBBackend::genChangeDomain(const DNSName& domain, const std::function<void(DomainInfo&)>& func)
{
auto txn = d_tdomains->getRWTransaction();
return true;
}
-int LMDBBackend::genChangeDomain(uint32_t id, std::function<void(DomainInfo&)> func)
+int LMDBBackend::genChangeDomain(uint32_t id, const std::function<void(DomainInfo&)>& func)
{
DomainInfo di;
void declareArguments(const string& suffix = "") override
{
declare(suffix, "filename", "Filename for lmdb", "./pdns.lmdb");
- declare(suffix, "sync-mode", "Synchronisation mode: nosync, nometasync, mapasync, sync", "mapasync");
+ declare(suffix, "sync-mode", "Synchronisation mode: nosync, nometasync, sync", "sync");
// there just is no room for more on 32 bit
declare(suffix, "shards", "Records database will be split into this number of shards", (sizeof(void*) == 4) ? "2" : "64");
declare(suffix, "schema-version", "Maximum allowed schema version to run on this DB. If a lower version is found, auto update is performed", std::to_string(SCHEMAVERSION));
public:
LMDBLoader()
{
- BackendMakers().report(new LMDBFactory);
+ BackendMakers().report(std::make_unique<LMDBFactory>());
g_log << Logger::Info << "[lmdbbackend] This is the lmdb backend version " VERSION
#ifndef REPRODUCIBLE
<< " (" __DATE__ " " __TIME__ ")"