Firestore Write Data Missing sometimes

We are using Firebase firestore with our simple grocery delivery app (android) for more than a year. Its super fast and great but it keeps missing data while writing.

Before, without using transactions and batched writes, the problem was much more persistent(about 10/1000 entries). After using the issue has been reduced but not completely gone(about 2/1000 entries).

Scenario:
We have few collections which are set/updated when the product is added namely products,stockand daylogs. When we add/update the product, the transaction writes different data to all these collections. But sometimes(2/1000), the transaction is successful and writes to products and stock but not daylogs.

Here is a simpler version of the code. Although, I don't think it's a code issue because it works fine 99% of the time.

  firebasefirestore.runTransaction(new Transaction.Function<String>() {
            @Override
            public String apply(@NonNull Transaction transaction) throws FirebaseFirestoreException {

                DocumentReference thisProduct = rootRef.collection("products").document(docId);
                DocumentReference thisStock = rootRef.collection("stock").document(docId);
                DocumentReference logs = rootRef.collection("daylogs").document(LogDocumentId);

                transaction.update(thisProduct, data);
                transaction.update(thisStock, data);
                transaction.update(logs, data);

                String complete = "1";
                return  complete;
            }

        }).addOnSuccessListener(new OnSuccessListener<String>() {
            @Override
            public void onSuccess(String result) {
                if (result.equals("1")) {
                  Toast.makeText(AddProduct.this, "Data Added", Toast.LENGTH_SHORT).show();
                } 
            }
        });

Why is this happening? And How can this be solved?
Sorry for my english. Please help.

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum