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 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思