Skip to content

Conversation

@namsic
Copy link
Collaborator

@namsic namsic commented Oct 16, 2025

πŸ”— Related Issue

  • jam2in/arcus-works#594
  • jam2in/arcus-works#790

⌨️ What I did

  • key의 μΌλΆ€λ§Œ shard 결정에 μ‚¬μš©ν•˜λ„λ‘ ν•©λ‹ˆλ‹€.
  • μ•„λž˜ 쑰건에 ν•΄λ‹Ήν•˜λŠ” 경우 {와 } 사이 λ¬Έμžμ—΄μ„ hash에 μ‚¬μš©ν•©λ‹ˆλ‹€.
    1. keyλŠ” { 포함
    2. { λ‹€μŒμ— } 쑴재
    3. 처음 λ“±μž₯ν•˜λŠ” {, 처음 λ“±μž₯ν•˜λŠ” } 문자 사이에 ν•˜λ‚˜ μ΄μƒμ˜ 문자 쑴재
  • κ·Έλ ‡μ§€ μ•Šμ€ 경우 κΈ°μ‘΄κ³Ό λ™μΌν•˜κ²Œ key 전체λ₯Ό hash에 μ‚¬μš©ν•©λ‹ˆλ‹€.

Copy link
Collaborator

@jhpark816 jhpark816 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰 μ™„λ£Œ

cluster_config.c Outdated
return NULL;
}

uint32_t remaining = nkey - (left - key) - 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remaining λ³€μˆ˜λŠ” μ œκ±°ν•©μ‹œλ‹€.

*nshardkey = right - left - 1;
if (*nshardkey == 0) {
return NULL;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ•„λž˜ 킀듀은 λͺ¨λ‘ ν‚€ 전체가 shard keyκ°€ λ˜λ‚˜μš”?
redis도 λ™μΌν•œ μ§€ κΆκΈˆν•©λ‹ˆλ‹€.

  • "aaa{}bbb}ccc"
  • "add{}{bbb}ccc"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ν‚€ 전체가 shard keyκ°€ λ˜λ‚˜μš”?

λ§žμŠ΅λ‹ˆλ‹€. μ•„λž˜ λ‚΄μš©μœΌλ‘œ 닡변이 될 것 κ°™μŠ΅λ‹ˆλ‹€.

https://redis.io/docs/latest/operate/oss_and_stack/reference/cluster-spec/#hash-tags

Examples:

  • The two keys {user1000}.following and {user1000}.followers will hash to the same hash slot since only the substring user1000 will be hashed in order to compute the hash slot.
  • For the key foo{}{bar} the whole key will be hashed as usual since the first occurrence of { is followed by } on the right without characters in the middle.
  • For the key foo{{bar}}zap the substring {bar will be hashed, because it is the substring between the first occurrence of { and the first occurrence of } on its right.
  • For the key foo{bar}{zap} the substring bar will be hashed, since the algorithm stops at the first valid or invalid (without bytes inside) match of { and }.
  • What follows from the algorithm is that if the key starts with {}, it is guaranteed to be hashed as a whole. This is useful when using binary data as key names.

cluster_config.c Outdated
hash_md5(shardkey, nshardkey, digest);
#else
hash_md5(key, nkey, digest);
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

μ•„λž˜ ν˜•νƒœμ˜ μ½”λ“œλ‘œ ν•˜λ©΄ μ’‹κ² μŠ΅λ‹ˆλ‹€.

#ifdef SHARD_KEY
    uint32_t nshardkey;
    const char *shardkey = get_shard_key(key, nkey, &nshardkey);
    if (shardkey) {
        key = shardkey;
        nkey = nshardkey;
    }
#endif 

    hash_md5(key, nkey, digest);

@namsic
Copy link
Collaborator Author

namsic commented Dec 2, 2025

μ•„λž˜μ™€ 같이 μˆ˜μ •λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

  • develop commit 반영
  • #ifdef 제거
  • prefix에 {, } ν—ˆμš©

@namsic namsic marked this pull request as ready for review December 2, 2025 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants