apache / apache/kvrocks

Prohibit the execution of cross-slot commands in MULTI

Open
#2,437 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C++
Stars
4.4k
Forks
658
Avg merge
1d 20h
Merged PRs (30d)
10

Description

### Search before asking

- [X] I had searched in the [issues](https://github.com/apache/kvrocks/issues) and found no similar issues.

### Motivation

I found this issue while trying to support scirpt flag `allow-cross-slot-keys`
Related discussions in redis:
https://github.com/redis/redis/issues/10503
https://github.com/redis/redis/issues/13140

kvrocks currently does not prohibit `cross-slot` in `MULTI-EXEC`. Is there any mechanism to provide protection? If not we should ban it.

### Solution

I noticed that there is `CanExecByMySelf` to make relevant judgments, but it seems to be only suitable for checking whether the slots of multiple keys operated by a single command are the same, but does not detect the situation of multiple commands (such as MULTI-EXEC and scirpt). We may need to track multiple Commands using slots.

### Are you willing to submit a PR?

- [ ] I'm willing to submit a PR!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing CanExecByMySelf and the MULTI-EXEC and script execution paths to see how key slots are currently checked. Determine where commands queued in a transaction can be tracked together, then verify that cross-slot transactions are rejected while same-slot transactions still execute normally. No specific files or tests are named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, redis
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.