Skip to content

Conversation

@singsangssong
Copy link
Collaborator

🔗 Related Issue

⌨️ What I did

원하는 key string을 하나의 노드에 저장할 수 있도록 그룹화하는 Shard Key 기능을 구현합니다.
shard 결정을 위해서는 key의 일부만을 사용하며, 해당 조건은 아래와 같습니다.

  • 키에 {...} 패턴이 포함될 경우, 전체 키 대신 {} 사이의 문자열만을 해싱하여 저장할 노드를 결정합니다.

    • 처음 등장하는 {와 처음 등장하는 } 사이의 하나 이상의 문자열을 해싱
  • 이를 통해 동일한 Shard Key를 가진 키들은 항상 같은 노드에 배치됨을 보장하도록 합니다.

  • 테스트코드는 새로운 ArcusShardKeyTest클래스를 추가했습니다.

    • 키 전체가 서로 다르더라도 하나의 노드에 모두 저장되는지 확인
    • shard key값이 다르다면 서로 다른 노드로 분산되는지 확인
    • 키에 Shard key 규칙에 관한 패턴이 없다면 전체 키를 통해 해싱하는지 확인

uhm0311

This comment was marked as resolved.

uhm0311
uhm0311 previously approved these changes Nov 27, 2025
@oliviarla

This comment was marked as resolved.

@singsangssong

This comment was marked as resolved.

@uhm0311

This comment was marked as resolved.

oliviarla

This comment was marked as resolved.

oliviarla
oliviarla previously approved these changes Dec 5, 2025
oliviarla
oliviarla previously approved these changes Dec 5, 2025
uhm0311
uhm0311 previously approved these changes Dec 5, 2025
@jhpark816 jhpark816 added the merged next time PR will be merged next time. label Dec 5, 2025
@singsangssong singsangssong dismissed stale reviews from uhm0311 and oliviarla via e4c2caf December 9, 2025 09:24
@singsangssong
Copy link
Collaborator Author

https://github.com/jam2in/arcus-works/issues/790#issuecomment-3629954750

위에서 코멘트 주신대로 useShardKey필드를 추가하고, shard key 사용 여부를 설정할 수 있도록 했습니다.
생성자 인자를 수정하면서, 관련된 부분도 수정했습니다. 참고부탁드립니다.

uhm0311
uhm0311 previously approved these changes Dec 10, 2025
@oliviarla
Copy link
Collaborator

MemcachedClient#validateKey 에서 {, } 가 prefix에 포함되어도 유효한 키로 간주해야 합니다.

@oliviarla
Copy link
Collaborator

리뷰 가능한 상태가 되면 요청 주세요.

@singsangssong
Copy link
Collaborator Author

@oliviarla @uhm0311
말씀해주신대로 validateKey()에서 {, }가 포함되어도 유효한 키가 되도록 수정했고, 연관된 다른 코드도 확인해본 결과 리뷰받아도 될 것 같습니다. 참고로 ArcusKetamaNodeLocator의 생성자가 변경되면서, 클래스를 사용하는 연관 코드들도 함께 수정되었습니다. 참고 부탁드립니다.

oliviarla
oliviarla previously approved these changes Dec 12, 2025
@oliviarla oliviarla requested a review from jhpark816 December 12, 2025 07:12
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.

리뷰 완료

private ArcusReplKetamaNodeLocator(TreeMap<Long, SortedSet<MemcachedReplicaGroup>> kg,
ConcurrentHashMap<String, MemcachedReplicaGroup> ag,
Collection<MemcachedNode> an) {
Collection<MemcachedNode> an, boolean shardKey) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ArcusReplKetamaNodeLocator 기존 생성자 구현에서는
config 인자를 가지도록 먼저 변경하는 것이 좋겠습니다.

@singsangssong
Copy link
Collaborator Author

testLibKetamaCompatTwo()의 테스트코드를 수정하면서 빌드 환경에서 "code too large'현상이 발생했습니다. (Java 메서드 바이트코드 64KB 제한 초과 에러) 이에 따라 테스트케이스 개수를 줄인점 참고부탁드립니다.

Copy link
Collaborator

@uhm0311 uhm0311 left a comment

Choose a reason for hiding this comment

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

질문입니다.

@singsangssong
Copy link
Collaborator Author

@oliviarla
재리뷰 요청드립니다.

@oliviarla oliviarla requested a review from jhpark816 December 18, 2025 01:31
@oliviarla
Copy link
Collaborator

commit message의 첫 문자를 대문자로 변경해주세요.

@jhpark816 jhpark816 merged commit 7140254 into naver:develop Dec 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged next time PR will be merged next time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants