MCPcopy Create free account
hub / github.com/apple/foundationdb / KeyValueStoreSQLite

Method KeyValueStoreSQLite

fdbserver/KeyValueStoreSQLite.actor.cpp:2133–2182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2131static int vfs_registered = 0;
2132
2133KeyValueStoreSQLite::KeyValueStoreSQLite(std::string const& filename,
2134 UID id,
2135 KeyValueStoreType storeType,
2136 bool checkChecksums,
2137 bool checkIntegrity)
2138 : type(storeType), logID(id), filename(filename), readThreads(CoroThreadPool::createThreadPool()),
2139 writeThread(CoroThreadPool::createThreadPool()), readsRequested(0), writesRequested(0), writesComplete(0),
2140 diskBytesUsed(0), freeListPages(0) {
2141 TraceEvent(SevDebug, "KeyValueStoreSQLiteCreate").detail("Filename", filename);
2142
2143 stopOnErr = stopOnError(this);
2144
2145#if SQLITE_THREADSAFE == 0
2146 ASSERT(writeThread->isCoro());
2147#endif
2148
2149 if (!vfs_registered && writeThread->isCoro())
2150 if (sqlite3_vfs_register(vfsAsync(), true) != SQLITE_OK)
2151 ASSERT(false);
2152
2153 // The DB file should not already be open
2154 ASSERT(!vfsAsyncIsOpen(filename));
2155 ASSERT(!vfsAsyncIsOpen(filename + "-wal"));
2156
2157 readCursors.resize(SERVER_KNOBS->SQLITE_READER_THREADS); //< number of read threads
2158
2159 sqlite3_soft_heap_limit64(SERVER_KNOBS->SOFT_HEAP_LIMIT); // SOMEDAY: Is this a performance issue? Should we drop
2160 // the cache sizes for individual threads?
2161 TaskPriority taskId = g_network->getCurrentTask();
2162 g_network->setCurrentTask(TaskPriority::DiskWrite);
2163 // Note: the below is actually a coroutine and not a thread.
2164 writeThread->addThread(new Writer(this,
2165 type == KeyValueStoreType::SSD_BTREE_V2,
2166 checkChecksums,
2167 checkIntegrity,
2168 writesComplete,
2169 springCleaningStats,
2170 diskBytesUsed,
2171 freeListPages,
2172 id,
2173 &readCursors),
2174 "fdb-sqlite-wr");
2175 g_network->setCurrentTask(taskId);
2176 auto p = new Writer::InitAction();
2177 auto f = p->result.getFuture();
2178 writeThread->post(p);
2179 starting = startReadThreadsWhen(this, f, logID);
2180 cleaning = cleanPeriodically(this);
2181 logging = logPeriodically(this);
2182}
2183KeyValueStoreSQLite::~KeyValueStoreSQLite() {
2184 // printf("dbf=%lld bytes, wal=%lld bytes\n", getFileSize((filename+".fdb").c_str()),
2185 // getFileSize((filename+".fdb-wal").c_str()));

Callers

nothing calls this directly

Calls 11

TraceEventClass · 0.85
vfsAsyncFunction · 0.85
vfsAsyncIsOpenFunction · 0.85
detailMethod · 0.80
isCoroMethod · 0.45
resizeMethod · 0.45
getCurrentTaskMethod · 0.45
setCurrentTaskMethod · 0.45
addThreadMethod · 0.45
getFutureMethod · 0.45
postMethod · 0.45

Tested by

no test coverage detected