简体   繁体   English

如果我在 ScalarDB 中启动事务但不提交会发生什么?

[英]What happens if I start a transaction in ScalarDB but do not commit it?

I am using ScalarDB to add ACID support in Cassandra application.我正在使用 ScalarDB 在Cassandra应用程序中添加 ACID 支持。 What happens if I start a Transaction but don't commit it.如果我开始一个Transaction但不提交它会发生什么。 Could there be any adverse effects of it?会不会有什么不良影响?

Eg.例如。

def somefunction=  {
    //Create the transaction
    val transaction: DistributedTransaction = transactionService.start
    if(all OK){
... //go ahead with DB operations
     commitTransaction(transaction) //OK
      (user: User, profileAndPortfolio: ExternalUserProfile, emailToken: UserToken)
    } else {
//miss commiting the transaction here
    }
  }

There is no effect.没有效果。 All mutations in a transaction are stored in the client's memory until the commit.事务中的所有突变都存储在客户端的 memory 中,直到提交。 Other transactions cannot see them and the datastore (Cassandra) doesn't receive any request for the mutations.其他事务看不到它们,并且数据存储区 (Cassandra) 没有收到任何突变请求。

To be more correct, it might cause an anomaly (read skew anomaly or read-only transaction anomaly) if you use SERIALIZABLE with read-only transactions and use the read data.更正确地说,如果您将 SERIALIZABLE 与只读事务一起使用并使用读取数据,则可能会导致异常(读取倾斜异常或只读事务异常)。

So as a best practice, it is always better to call commit.因此,作为最佳实践,调用 commit 总是更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM