Skip to content

Commit

Permalink
more fiddling
Browse files Browse the repository at this point in the history
  • Loading branch information
cldellow committed Oct 5, 2024
1 parent 0f3a403 commit d11dabc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/mbtiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ void MBTiles::openForReading(string &filename) {
std::string uri = "file:";
uri += filename;
uri += "?immutable=1&mode=ro";
db.init(uri.c_str(), SQLITE_OPEN_READONLY | SQLITE_OPEN_URI | SQLITE_OPEN_NOMUTEX);
//db.init(uri.c_str(), SQLITE_OPEN_READONLY | SQLITE_OPEN_URI | SQLITE_OPEN_NOMUTEX);
db.init(uri.c_str(), SQLITE_OPEN_READONLY | SQLITE_OPEN_URI);
this->filename = filename;

/*
Expand Down
32 changes: 21 additions & 11 deletions src/tilemaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,27 @@ int main(const int argc, const char* argv[]) {
return 1;
}

// Per https://www.sqlite.org/c3ref/c_config_covering_index_scan.html#sqliteconfigsinglethread,
// this should break everything.
//
// But things seem to still work, and this avoids the locking we were seeing.
//
// I would have thought we needed SQLITE_CONFIG_MULTITHREAD ? I feel like
// I'm missing something pretty big here, but let's go until we hit a wall.
int rv = sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
if (rv) {
std::cerr << "fatal: sqlite3_config(SQLITE_CONFIG_SINGLETHREAD)=" << std::to_string(rv) << std::endl;
return 1;
{
// See https://github.com/xerial/sqlite-jdbc/issues/59#issuecomment-162115704
int rv;
rv = sqlite3_config(SQLITE_CONFIG_MEMSTATUS, 0);
if (rv) {
std::cerr << "fatal: sqlite3_config(SQLITE_CONFIG_MEMSTATUS)=" << std::to_string(rv) << std::endl;
return 1;
}

// Per https://www.sqlite.org/c3ref/c_config_covering_index_scan.html#sqliteconfigsinglethread,
// this should break everything.
//
// But things seem to still work, and this avoids the locking we were seeing.
//
// I would have thought we needed SQLITE_CONFIG_MULTITHREAD ? I feel like
// I'm missing something pretty big here, but let's go until we hit a wall.
rv = sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
if (rv) {
std::cerr << "fatal: sqlite3_config(SQLITE_CONFIG_SINGLETHREAD)=" << std::to_string(rv) << std::endl;
return 1;
}
}
std::string MergedFilename("merged.mbtiles");
remove(MergedFilename.c_str());
Expand Down

0 comments on commit d11dabc

Please sign in to comment.