一致的N1QL查询Couchbase GOCB SDK

我当前正在为Go Actor lib实现EventSourcing。
我现在遇到的问题是 actor重新启动并需要从事件日志中重播所有状态,该查询可能返回不一致的数据。
我知道我可以使用 MutationToken </ code> </ p>

解决此问题 ,如果这样做,我将被迫按顺序写入所有事件,即最后写入最后一个事件。</ p>

这样,最后一个事件的突变令牌就足够了 才能始终如一地获取特定演员的所有数据。</ p>

但这非常慢,依次写入约10000个事件,大约需要5秒钟。</ p>

如果我改为使用go例程编写那些10000异步代码,则可以在不到一秒钟的时间内写入所有数据。
但是,写入顺序不确定,因此我可以知道可以使用哪个突变令牌 信任。
e.g。 由于要进行例行调度AFAIK,因此可能在事件843之前编写了事件999。</ p>

我在这里有什么选择?</ p>
</ div>

展开原文

原文

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个回答



从技术上讲,MutationToken和异步操作不是互斥的。 可以在不更改客户端的情况下完成此操作(我不确定),但是这里的关键是获取所有MutationToken响应,然后使用所有vbucket发出具有最高编号的查询。</ p>

关键是给定一个 MutationToken < / a>,您可以将其他添加到其中。 我没有直接看到执行此操作的方法,但是由于在内部它只是一张地图,因此应该相对简单明了,并且我相信我们(Couchbase)将为此做出贡献。 在最低级别上,只是发出查询时提供给查询的vbucket序列图。</ p>
</ div>

展开原文

原文

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.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问