fix: treat "sinter sunion sdiff" as wrtie commands #2364
Merged
+3
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#2363
Floyd 采用多 RocksDB 实例,每个 Key 可能 Hash 到不同的 RocksDB 实例,与 BlackWidow 不同的是 Floyd 下的 Key 不再以数据类型去区分 RocksDB, 即一个 RocksDB 下可能会存在不同类型的 Key,那么对于 Redis 命令中如:SInter 这种操作多个 Key 的情况下,需要重新设计下确保操作的一致性,对 BlackWidow 来说对于 Sinter 这种命令,由于所有的 Set 类型都在同一个 RocksDB 下,所以对于 SInter 这种读命令不需要进行上 key 锁,只需要在相应的 RocksDB 打一个快照然后进行操作即可,但是在 Floyd 下,多个 Key 可能存在多个 RocksDB 下,对于这种问题我们需要一种解决方式。
经过讨论,我们总结出了三种方案解决:
sinter
这种命令由原来的读命令设置为写命令,在 CMD 层面上 Key 锁,这样就能完美的解决 Floyd 中的多 key 问题,缺点是inster
这种本来是读命令不需要进行上锁操作的会变为写命令,但是能保证数据的一致性sinter
这种操作多key
的命令,我们在 Cmd 层上写锁,然后同时在CMD
层打好每个Key
对应 Hash 到的RocksDB
实例的快照,然后以入参的方式从CMD
层一直传到Redis
层,这样上锁的粒度会比较小,但是代码的改动量会特别大,会对CMD
,Storage
,Redis
这三层的接口都需要进行修改,同时还需要对Floyd
的测试也进行修改Storage
层上Key
锁,和上面的CMD
层上Key
锁一样,少了CMD
层对Storage
层的snapshot
入参,但是需要在Storage
中所有的写命令接口中全部上Key
锁,这样的实现方式在Redis
,CMD
,Storage
层都加上了Key
锁,感觉代码冗余总结
这个 PR 中我们采用了第一种解决方案,这也是改动量最小,并且能解决多
Key
操作时的一致性问题