googleapis / googleapis/google-cloud-php

Clarification or Solution for Atomic Operations Post batch() Deprecation

Open
#8,010 1 comment 0 reactions 1 assignee Claimed by @Hectorhammett View on GitHub
api: firestore
Dominant language
PHP
Stars
1.2k
Forks
463
Avg merge
2d 1h
Merged PRs (30d)
145

Description

With the deprecation of the batch() method in the Firestore PHP SDK, I noticed that BulkWriter is being recommended as an alternative for performing multiple writes. However, it's unclear whether BulkWriter supports atomic write operations, where all writes either succeed or fail as a single unit.

Previously, the batch() method allowed for atomic operations using Google\Cloud\Firestore\WriteBatch. This feature was crucial for maintaining data consistency in scenarios where multiple writes needed to be applied together.

I came across [this detailed comparison of Batched Writes vs. BulkWriter](https://gist.github.com/GabiGrin/5e987a4b173b373e3474c8dab99736a8), which indicates that only Batched Writes support atomicity. While this aligns with the current understanding, I would like to confirm directly with the Google Cloud PHP development team whether BulkWriter provides a way to perform atomic writes or if there is another recommended alternative post-batch() deprecation.

**Observation**

I recently noticed an issue where duplicate increments occurred on a value in a Firestore collection. Unfortunately, I don’t have proper logs to confirm the root cause, but I suspect it might be related to BulkWriter retrying failed writes. This raised concerns about whether BulkWriter can guarantee atomicity or if retries might lead to inconsistent results in certain scenarios.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.