Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch sqlite temp storage to disk; fix failures in V16 #11600

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion AnkiDroid/src/main/java/com/ichi2/libanki/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public static Collection Collection(Context context, @NonNull String path, boole
} else {
ver = _upgradeSchema(db, time);
}
db.execute("PRAGMA temp_store = memory");
// add db to col and do any remaining upgrades
Collection col = backend.createCollection(context, db, path, server, log);
if (ver < Consts.SCHEMA_VERSION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.ichi2.libanki.backend

import android.system.Os
import androidx.annotation.VisibleForTesting
import com.ichi2.anki.AnkiDroidApp
import com.ichi2.anki.CrashReportService
Expand All @@ -37,6 +38,9 @@ object DroidBackendFactory {
@JvmStatic
@RustCleanup("Change back to a constant SYNC_VER")
fun getInstance(useBackend: Boolean): DroidBackend {
// Prevent sqlite throwing error 6410 due to the lack of /tmp
val dir = AnkiDroidApp.getInstance().applicationContext.cacheDir
Os.setenv("TMPDIR", dir.path, false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion began here: ankitects/anki@f15e294#r75810592

I'm +1 on this change I think it is the only way to be sure we won't overflow JVM heap on android

if (sBackendForTesting != null) {
return sBackendForTesting!!
}
Expand Down