简体   繁体   English

Aerospike 集群中的多个集合(表)上的多个操作

[英]Multiple Operations on Multiple Sets (Tables) in Aerospike cluster

Current system state:当前系统 state:

Currently, I maintain three sets (tables, equivalent in RDBMS) in my aerospike namespace (database, equivalent in RDBMS) backed by RESTful service.目前,我在由 RESTful 服务支持的 aerospike 命名空间(数据库,在 RDBMS 中等效)中维护了三个集合(表,在 RDBMS 中等效)。

Use-case:用例:

I want to perform CRUD operations on at least one set and sometimes at most on all sets based on some bulk inputs into my system.我想根据对我系统的一些批量输入,对至少一个集合执行 CRUD 操作,有时最多对所有集合执行 CRUD 操作。

Expectation:期待:

I want to perform all these CRUD operations in an atomic manner (means either all happen or none. This also contains an edge-case where some sets are successfully updated with their respective latest updates, and later on even a single set is un-successful. I would want to rollback my data to the previous state in each set.)我想以原子方式执行所有这些 CRUD 操作(意味着要么全部发生,要么都不发生。这还包含一个边缘情况,其中一些集合已成功更新其各自的最新更新,后来甚至单个集合都不成功. 我想将我的数据回滚到每组中以前的 state。)

My workaround:我的解决方法:

  1. First I tried to find the equivalent of InsertOnSubmit in aerospike to use the approaches explained on this answer of StackOverflow , but seems like that doesn't exist.首先,我尝试在 aerospike 中找到与InsertOnSubmit等效的方法,以使用StackOverflow 的答案中解释的方法,但似乎不存在。
  2. Second, I thought of creating an intermediate rollback workflow module.其次,我想到了创建一个中间回滚工作流模块。 Psuedo code shown below:伪代码如下所示:

    1. Temporarily save the new data in some data-type segregated set-wise.将新数据临时保存在某些数据类型中,按集合方式隔离。
    2. Loop through set-wise data, and pick the primary key from them and get the older data from aerospike and save it into some other data-type again segregated set-wise.循环遍历集合数据,从中选择主键并从 aerospike 获取较旧的数据,并将其保存到其他数据类型中,再次以集合方式隔离。
    3. Loop through all the sets one-by-one from first data-type and start performing CRUD operation accordingly.从第一个数据类型开始逐个循环遍历所有集合,并相应地开始执行 CRUD 操作。 IF[everything runs till the end]: GOTO step 6; ELSE: GOTO step 4 IF[everything runs till the end]: GOTO step 6; ELSE: GOTO step 4 . IF[everything runs till the end]: GOTO step 6; ELSE: GOTO step 4
    4. Start rolling-back by looping through all the sets one-by-one from second data-type and start performing CRUD operation.通过从第二种数据类型开始逐一循环所有集合并开始执行 CRUD 操作来开始回滚。 IF[everything runs till the end]: GOTO step 7; ELSE: GOTO step 5 IF[everything runs till the end]: GOTO step 7; ELSE: GOTO step 5 . IF[everything runs till the end]: GOTO step 7; ELSE: GOTO step 5
    5. Log the error including all the details and report this error to alert system.记录错误,包括所有详细信息,并将此错误报告给警报系统。 Someone will get paged for it to have a look.有人会被传呼给它看看。 GO TO step 7;
    6. Terminate, operation successful.终止,操作成功。
    7. Terminate, operation un-successful.终止,操作不成功。

Help Needed:需要帮助:

  1. Is there any chance to incoperate InsertOnSubmit behaviour on Aerospike cluster without creating my own roll-back workflow?在不创建我自己的回滚工作流的情况下,是否有机会在 Aerospike 集群上阻止InsertOnSubmit行为?
  2. If not, then is there any better way to optimize my second approach?如果没有,那么有没有更好的方法来优化我的第二种方法?

1 - No. Aerospike offers atomicity only at a single record level. 1 - 没有。Aerospike 仅在单个记录级别提供原子性。 While inserting Master record and then replicating its copy to another node do follow true 2-phase commit semantics in Aerospike's Strong Consistency (SC) mode, any multi-record transaction has to be implemented at the application level.在插入主记录然后将其副本复制到另一个节点时,在 Aerospike 的强一致性 (SC) 模式下确实遵循真正的两阶段提交语义,任何多记录事务都必须在应用程序级别实现。

2 - Any scheme implementing multi-record transactions, such as one you are thinking of, typically involves - creating some kind of "lock" bin in a record that you set, do the multi-record updates, build a before and after state of your data, have some kind of a maximum time to complete so you can rollback and clear abandoned operations and lock by the client application. 2 - 任何实现多记录事务的方案,例如您正在考虑的方案,通常涉及 - 在您设置的记录中创建某种“锁定”箱,进行多记录更新,在 state 之前和之后构建您的数据,有某种最长时间来完成,以便您可以回滚并清除客户端应用程序的放弃操作和锁定。 Any of these schemes will only work reliably under Aerospike's Strong Consistency mode.这些方案中的任何一个都只能在 Aerospike 的强一致性模式下可靠地工作。

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

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