dpus81500574 2016-10-02 08:54
浏览 76

一致的N1QL查询Couchbase GOCB SDK

I'm currently implementing EventSourcing for my Go Actor lib. The problem that I have right now is that when an actor restarts and need to replay all it's state from the event journal, the query might return inconsistent data. I know that I can solve this using MutationToken

But, if I do that, I would be forced to write all events in sequential order, that is, write the last event last.

That way the mutation token for the last event would be enough to get all the data consistently for the specific actor.

This is however very slow, writing about 10 000 events in order, takes about 5 sec on my setup.

If I instead write those 10 000 async, using go routines, I can write all of the data in less than one sec. But, then the writes are in indeterministic order and I can know which mutation token I can trust. e.g. Event 999 might be written before Event 843 due to go routine scheduling AFAIK.

What are my options here?

  • 写回答

1条回答 默认 最新

  • douzhi4056 2016-10-04 01:47
    关注

    Technically speaking MutationToken and asynchronous operations are not mutually exclusive. It may be able to be done without a change to the client (I'm not sure) but the key here is to take all MutationToken responses and then issue the query with the highest number per vbucket with all of them.

    The key here is that given a single MutationToken, you can add the others to it. I don't directly see a way to do this, but since internally it's just a map it should be relatively straightforward and I'm sure we (Couchbase) would take a contribution that does this. At the lowest level, it's just a map of vbucket sequences that is provided to query at the time the query is issued.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?