Skip to content

Firestore fails to read large write batches #208

@brucemax

Description

@brucemax

[REQUIRED] Step 2: My environment

  • Android Studio version: 3.3
  • Firebase Component: Firestore
  • Component version: 17.1.5

[REQUIRED] Step 3: Describe the problem

Some my app user get this crash during batch.commit() (HUAWEI VTR-L09 Android 8.0.0)

Fatal Exception: java.lang.RuntimeException: Internal error in Firestore (0.6.6-dev).
at com.google.firebase.firestore.util.AsyncQueue.lambda$panic$5(com.google.firebase:firebase-firestore@@17.1.5:377)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$5.run(Unknown Source:2)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:101)
at android.os.Looper.loop(Looper.java:166)
at android.app.ActivityThread.main(ActivityThread.java:7523)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

Caused by java.lang.RuntimeException: java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at com.google.firebase.firestore.util.AsyncQueue.enqueue(com.google.firebase:firebase-firestore@@17.1.5:288)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@17.1.5:203)
at java.lang.Thread.run(Thread.java:784)

Caused by java.lang.IllegalStateException: Couldn't read row 0, col 0 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetBlob(CursorWindow.java)
at android.database.CursorWindow.getBlob(CursorWindow.java:405)
at android.database.AbstractWindowedCursor.getBlob(AbstractWindowedCursor.java:45)
at com.google.firebase.firestore.local.SQLiteMutationQueue.lambda$getNextMutationBatchAfterBatchId$4(com.google.firebase:firebase-firestore@@17.1.5:248)
at com.google.firebase.firestore.local.SQLiteMutationQueue$$Lambda$5.apply(Unknown Source:4)
at com.google.firebase.firestore.local.SQLitePersistence$Query.firstValue(com.google.firebase:firebase-firestore@@17.1.5:442)
at com.google.firebase.firestore.local.SQLiteMutationQueue.getNextMutationBatchAfterBatchId(com.google.firebase:firebase-firestore@@17.1.5:248)
at com.google.firebase.firestore.local.LocalStore.getNextMutationBatch(com.google.firebase:firebase-firestore@@17.1.5:451)
at com.google.firebase.firestore.remote.RemoteStore.fillWritePipeline(com.google.firebase:firebase-firestore@@17.1.5:539)
at com.google.firebase.firestore.remote.RemoteStore.enableNetwork(com.google.firebase:firebase-firestore@@17.1.5:221)
at com.google.firebase.firestore.remote.RemoteStore.start(com.google.firebase:firebase-firestore@@17.1.5:252)
at com.google.firebase.firestore.core.FirestoreClient.initialize(com.google.firebase:firebase-firestore@@17.1.5:225)
at com.google.firebase.firestore.core.FirestoreClient.lambda$new$2(com.google.firebase:firebase-firestore@@17.1.5:108)
at com.google.firebase.firestore.core.FirestoreClient$$Lambda$2.run(Unknown Source:8)
at com.google.firebase.firestore.util.AsyncQueue.lambda$enqueue$4(com.google.firebase:firebase-firestore@@17.1.5:309)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$4.call(Unknown Source:2)
at com.google.firebase.firestore.util.AsyncQueue.enqueue(com.google.firebase:firebase-firestore@@17.1.5:285)
at com.google.firebase.firestore.util.AsyncQueue$$Lambda$3.run(Unknown Source:4)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at com.google.firebase.firestore.util.AsyncQueue$DelayedStartFactory.run(com.google.firebase:firebase-firestore@@17.1.5:203)
at java.lang.Thread.run(Thread.java:784)

Relevant Code:

Init Firestore

FirebaseFirestore db = FirebaseFirestore.getInstance();
            FirebaseFirestoreSettings settings = new FirebaseFirestoreSettings.Builder()
                    .setTimestampsInSnapshotsEnabled(true)
                    .build();
            db.setFirestoreSettings(settings);
if (realmTablesResult.size() > 0) {
            WriteBatch batch = db.batch();
            Gson gson = new Gson();
            List<HistoryTrainingTable> arrayListOfUnmanagedObjects = realm.copyFromRealm(realmTablesResult);
            for (HistoryTrainingTable historyTrainingTable : arrayListOfUnmanagedObjects) {
                FATrainingTableHistory historyItem = new FATrainingTableHistory();
                historyItem.id = historyTrainingTable.getId();
                historyItem.trainingDate = historyTrainingTable.getTrainingDate();
                historyItem.description = gson.toJson(historyTrainingTable);
                historyItem.bestTimeValue = historyTrainingTable.getBestTimeValue();
                historyItem.avgContractionTime = historyTrainingTable.getAvgContractionTime();

                DocumentReference nycRef = db.collection("history/" + userId + "/userHistory/").document(String.valueOf(historyTrainingTable.getId()));
                batch.set(nycRef, historyItem);
            }


            // Commit the batch
            batch.commit().addOnCompleteListener(new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    Log.d("myTag", "batch.commit() complete");
                }
            });
        }

        db.collection("history/"+userId+"/userHistory/")
                .get()
public class FATrainingTableHistory {

    public String id;
    public String description;
    public int bestTimeValue;
    public Date trainingDate;
    public int avgContractionTime;
}

Metadata

Metadata

Assignees

Labels

type: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions