Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Fix bug of auto_vacuum not working
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpsantos committed Jun 13, 2019
1 parent 5b4bb13 commit bf0be56
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions platform/default/src/mbgl/storage/offline_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ void OfflineDatabase::removeOldCacheTable() {

void OfflineDatabase::createSchema() {
assert(db);
db->exec("PRAGMA auto_vacuum = INCREMENTAL");
db->exec("PRAGMA journal_mode = DELETE");
db->exec("PRAGMA synchronous = FULL");
mapbox::sqlite::Transaction transaction(*db);
Expand All @@ -140,7 +139,6 @@ void OfflineDatabase::createSchema() {

void OfflineDatabase::migrateToVersion3() {
assert(db);
db->exec("PRAGMA auto_vacuum = INCREMENTAL");
db->exec("VACUUM");
db->exec("PRAGMA user_version = 3");
}
Expand Down Expand Up @@ -636,7 +634,7 @@ std::exception_ptr OfflineDatabase::clearTileCache() try {

query.run();

db->exec("PRAGMA incremental_vacuum");
db->exec("VACUUM");

return nullptr;
} catch (const mapbox::sqlite::Exception& ex) {
Expand Down Expand Up @@ -811,7 +809,7 @@ std::exception_ptr OfflineDatabase::deleteRegion(OfflineRegion&& region) try {

evict(0);
assert(db);
db->exec("PRAGMA incremental_vacuum");
db->exec("VACUUM");

// Ensure that the cached offlineTileCount value is recalculated.
offlineMapboxTileCount = {};
Expand Down Expand Up @@ -1070,11 +1068,11 @@ T OfflineDatabase::getPragma(const char* sql) {
// less than the maximum cache size. Returns false if this condition cannot be
// satisfied.
//
// SQLite database never shrinks in size unless we call VACCUM. We here
// SQLite database never shrinks in size unless we call VACUUM. We here
// are monitoring the soft limit (i.e. number of free pages in the file)
// and as it approaches to the hard limit (i.e. the actual file size) we
// delete an arbitrary number of old cache entries. The free pages approach saves
// us from calling VACCUM or keeping a running total, which can be costly.
// us from calling VACUUM or keeping a running total, which can be costly.
bool OfflineDatabase::evict(uint64_t neededFreeSize) {
uint64_t pageSize = getPragma<int64_t>("PRAGMA page_size");
uint64_t pageCount = getPragma<int64_t>("PRAGMA page_count");
Expand Down

0 comments on commit bf0be56

Please sign in to comment.