Repository navigation
Harden OfflineDatabase - #12224
Harden OfflineDatabase#12224
Conversation
friedbunny
left a comment
There was a problem hiding this comment.
This looks like it has an inadvertent bump of the platform/ios/vendor/mapbox-events-ios submodule.
Please also add an iOS changelog entry. 🙇
0fecaed to
cd3880e
Compare
jfirebaugh
left a comment
There was a problem hiding this comment.
We'll need to think about what the behavior should be when an offline download encounters a database error. For instance, if the disk is full, it looks like the current behavior may be indistinguishable from a successful download.
| if (auto download = getDownload(regionID)) { | ||
| callback({}, download->getStatus()); | ||
| } else { | ||
| callback(std::current_exception(), {}); |
There was a problem hiding this comment.
std::current_exception() will always return an empty result here, since it's no longer inside a catch block.
There was a problem hiding this comment.
This is still pending; it should synthesize an exception. Also, listRegions, createRegion, and updateMetadata above and deleteRegion below need a similar change.
| : path(std::move(path_)), | ||
| maximumCacheSize(maximumCacheSize_) { | ||
| ensureSchema(); | ||
| try { |
| void migrateToVersion5(); | ||
| void migrateToVersion6(); | ||
| void migrateToVersion3(); | ||
| void migrateToVersion6(); |
| OfflineRegionDefinition definition { "", LatLngBounds::hull({1, 2}, {3, 4}), 5, 6, 1.0 }; | ||
| OfflineRegionMetadata metadata; | ||
| return db.createRegion(definition, metadata); | ||
| return db.createRegion(definition, metadata); |
|
Fixes #10031 |
528dd63 to
e1b23db
Compare
The current behavior is to crash if the disk is full (or any IO error occurs). When a network error occurs, the offline download never completes. This PR changes the crash when the disk is full to an offline download that never completes, which, while not ideal, is arguably better than the previous behavior. I think erroneous downloads is something worth fixing, but I'd like to do that in a followup PR to avoid delaying the important crash fixes in this PR even longer. Overall, I think we need a concept for what an offline download should do in the error case: Retry a few times? Record failures and add them to the status? How are sparse tilesets handled (they return 404s on purpose, which means such a download will never complete atm)? What happens when you go offline mid-download, or try to do a download over a spotty connection? |
|
Considering the call sequence If However, there will be at least one resource that does not trigger an increment of
If it's a permanent error, that's true. But transient errors will get retried, since
404s get turned into "no content" non-errors by the file source. We might need to take this into account if we change that behavior though. |
02564b6 to
03a4dc2
Compare
|
I fixed the test issues when using the VFS by porting the creation/deletion routines for |
|
@kkaefer took this PR for a testrun and it's looking great! Testrun
I'm seeing is that the |
5fa7f67 to
0c90386
Compare
I think the expected behavior is that a fresh application start isn't required, so this may need more investigation. |
|
Implemented database recreating when it is deleted in |
0933103 to
e783076
Compare
|
This is now ready for review 🎉 |
jfirebaugh
left a comment
There was a problem hiding this comment.
Awesome! Having an expected polyfill will definitely be useful.
This changes
OfflineDatabaseto be more resilient. The design is to catch SQLite exceptions on the body of all public functions, and return with a failure code if the query failed.Also adds tests for corrupt databases, as well as support for operating without read or write access to the file system. Also handles disk full error (in those cases, the database remains readable, but any updates, such as timestamp updates or resource insertions) will fail.