firebase - 我们是否为失败的 Firestore 交易收费

标签 firebase google-cloud-firestore

如果一个事务读取了 3 个文档,然后成功更新了 2 个文档,但此后的某些操作导致事务失败......我是否会为已回滚的 3 次读取和 2 次写入付费?

编辑---

另外,下面的 get() 是否只需要 1 次读取?其中 col2 是 doc1 的子集合。

db.collection('col1').doc('doc1').collection('col2').doc('doc2').get();

编辑 2

firebase 网站声明如下

For example, if a transaction reads documents and another client modifies any of those documents, Cloud Firestore retries the transaction. This feature ensures that the transaction runs on up-to-date and consistent data.

假设我的事务对 10 个不同的文档执行 10 次读取。如果它被调用并且在执行期间一些相同的文档被其他用户更新,这将使事务重试,我是否会被 10 * 重试读取次数击中?

编辑 3

我在这里阅读了更多关于交易的信息 https://firebase.google.com/docs/firestore/transaction-data-contention它声明服务器端事务将锁定文档并等待事务完成。

q1) 由于事务正在锁定而不是一遍又一遍地重试... 对具有事务的 firebase 函数的多个并发调用是否不会花费任何额外的读/写并且函数是否会因为执行而花费更长的时间锁?

q2) 该网页底部还有一个横幅,上面写着

Note: Only the server client libraries support transactions with read operations after write operations. For transactions in the mobile/web SDKs, document reads must come before document writes.

我刚刚在我的 firebase 函数上尝试了这个并收到以下错误...

Error: Firestore transactions require all reads to be executed before all writes.
    at Transaction.get (/srv/node_modules/@google-cloud/firestore/build/src/transaction.js:76:19)

我使用的是 firebase admin 版本“^8.8.0”,在写入后执行读取是新版本中添加的功能吗?

最佳答案

If transactions fail, will I still be charged?

是的。阅读已完成,因此您需要为此付费。 (我不确定是否有任何“回滚费用”——因为现在需要撤销更改。)

What is the cost of a sub-collection document read?

doc1 未被读取 - 因此不会收费。您只需为一次阅读付费。

我无法在文档中找到明确的文本,这些答案来 self 个人使用 Firebase 多年的经验。 Firebasers 的确认会很有帮助。

关于firebase - 我们是否为失败的 Firestore 交易收费,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64184466/

相关文章:

firebase - 如何从 React Native Firebase Analytics 的屏幕跟踪中删除 MainActivity 和 UIViewController?

android - 由于QuerySnapshot为null,即使在initState()中初始化后,也对null调用了getter 'docs'

firebase - 具有自定义错误消息和状态代码的 Firestore 安全规则

ios - Firestore 仍然会覆盖我的数据吗?

swift - 如何读取数据类型Dictionary来输入[String]?

firebase - Flutter 应用在​​ Release 模式下使用 Firestore 插件时崩溃

javascript - 为什么分页不起作用?

javascript - .get() 函数获取 firebase 文档 "is not a function"

javascript - 使用 firebase 创建简单例份验证的最佳方法是什么?

javascript - Dart-从字符串中提取日期(MM/DD/YYYY)