Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Fix do_command_dupcheck method that didn't show 0 at same key #794

Merged
merged 1 commit into from
Oct 29, 2024

Conversation

cheesecrust
Copy link

@cheesecrust cheesecrust commented Oct 25, 2024

πŸ”— Related Issue

⌨️ What I did

  • 이미 μ ‘κ·Όν•œ 킀에 λŒ€ν•΄μ„œ 전체에 μ ‘κ·Όν•˜λŠ” μ—°μ‚° (ex: sop get arcus 0)을 λ‚˜μ€‘μ— μ‹€ν–‰μ‹œν‚€λ©΄ lqdetect show μ—μ„œ λΉ μ§€λŠ” 버그λ₯Ό μˆ˜μ •ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

lqdetect.c Outdated Show resolved Hide resolved
@jhpark816
Copy link
Collaborator

lqdetect λͺ…령어듀이 κ³΅ν†΅μ μœΌλ‘œ μ‚¬μš©ν•˜λŠ” λ‘œμ§μ„ λ°–μœΌλ‘œ λΉΌλ‚΄μ–΄ κ°„μ†Œν™” μ‹œμΌ°μŠ΅λ‹ˆλ‹€.

버그 μˆ˜μ •λ§Œ ν¬ν•¨μ‹œν‚€κ³ , μœ„μ˜ μˆ˜μ •μ€ μ œμ™Έν•˜λŠ” 것이 쒋을 것 κ°™μ€λ°μš”. 의견이 μ–΄λ–€κ°€μš”?

@cheesecrust
Copy link
Author

cheesecrust commented Oct 28, 2024

버그 μˆ˜μ •λ§Œ ν¬ν•¨μ‹œν‚€κ³ , μœ„μ˜ μˆ˜μ •μ€ μ œμ™Έν•˜λŠ” 것이 쒋을 것 κ°™μ€λ°μš”. 의견이 μ–΄λ–€κ°€μš”?

버그 μˆ˜μ •λ§Œμ„ ν¬ν•¨ν•˜λ„λ‘ μˆ˜μ • ν–ˆμŠ΅λ‹ˆλ‹€.

@jhpark816 jhpark816 requested a review from namsic October 28, 2024 02:26
@namsic
Copy link
Collaborator

namsic commented Oct 28, 2024

전체 쑰회 (sop get skey 0) λͺ…령을 λ¨Όμ € λ³΄λ‚΄λŠ”κ°€ λ‚˜μ€‘μ— λ³΄λ‚΄λŠ”κ°€ ν•˜λŠ” λ¬Έμ œλŠ” μ°¨μΉ˜ν•˜κ³ ,
ν˜„μž¬ develop branch와 PR λͺ¨λ‘ μ•„λž˜μ™€ 같이 λ™μž‘ν•©λ‹ˆλ‹€.

lqdetect start 1
        long query detection started.

sop get skey1 0
sop get skey2 0
sop get skey1 1
sop get skey2 1

lqdetect show
sop get : 4
12:16:52.262987 127.0.0.1 <1> sop get skey1 0
12:17:07.816425 127.0.0.1 <1> sop get skey2 0
12:17:11.983276 127.0.0.1 <1> sop get skey1 1

μœ„ κ²°κ³Όλ₯Ό 보면, sop get skey2 1 연산은 좜λ ₯λ˜μ§€ μ•Šμ•˜λŠ”λ°, dupcheck 연산이 μ•„λž˜μ™€ 같은 λ‘œμ§μ„ κ°–κΈ° λ•Œλ¬Έμž…λ‹ˆλ‹€.

  • countκ°€ 0인 경우
    • (countλŠ” 항상 λ™μΌν•˜λ―€λ‘œ) λŒ€μƒ keyκ°€ 달라지면 false
  • countκ°€ 1 이상인 경우
    • count 값이 κ°™μœΌλ©΄ keyκ°€ 달라도 true

즉 sop get skey1 0κ³Ό sop get skey2 0은 λͺ¨λ‘ κΈ°λ‘ν•˜κ³ ,
sop get skey1 5와 sop get skey2 5λŠ” 쀑볡 μ²˜λ¦¬ν•˜μ—¬ ν•˜λ‚˜λ§Œ κΈ°λ‘ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

@jhpark816
제 μƒκ°μ—λŠ” countκ°€ 0인지 μ•„λ‹Œμ§€μ™€ λ¬΄κ΄€ν•˜κ²Œ μ•„λž˜ λ‘˜ 쀑 ν•˜λ‚˜λ‘œ 톡일해야 ν•  것 같은데, ν˜Ήμ‹œ ν˜„μž¬ λ™μž‘μ΄ μ˜λ„λœ μ„€κ³„μΈκ°€μš”?

  1. countκ°€ 같더라도 keyκ°€ λ‹€λ₯΄λ©΄ λͺ¨λ‘ 기둝
  2. countκ°€ κ°™μœΌλ©΄ keyκ°€ λ‹€λ₯΄λ”라도 ν•˜λ‚˜λ§Œ 기둝

Copy link
Collaborator

@namsic namsic left a comment

Choose a reason for hiding this comment

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

ν…ŒμŠ€νŠΈ κ΄€λ ¨ 리뷰만 μš°μ„  μž‘μ„±ν•©λ‹ˆλ‹€.

t/long_query_detect_issue.t Outdated Show resolved Hide resolved
t/long_query_detect_issue.t Outdated Show resolved Hide resolved
t/long_query_detect_issue.t Outdated Show resolved Hide resolved
@cheesecrust cheesecrust marked this pull request as draft October 28, 2024 04:11
@jhpark816
Copy link
Collaborator

제 μƒκ°μ—λŠ” countκ°€ 0인지 μ•„λ‹Œμ§€μ™€ λ¬΄κ΄€ν•˜κ²Œ μ•„λž˜ λ‘˜ 쀑 ν•˜λ‚˜λ‘œ 톡일해야 ν•  것 같은데, ν˜Ήμ‹œ ν˜„μž¬ λ™μž‘μ΄ μ˜λ„λœ μ„€κ³„μΈκ°€μš”?

μ˜λ„ν•œ μ„€κ³„μž…λ‹ˆλ‹€.

  • count = 0이면, ν•΄λ‹Ή set 크기에 따라 long query μ—¬λΆ€κ°€ κ²°μ •λ©λ‹ˆλ‹€. λ”°λΌμ„œ, ν•΄λ‹Ή keyλ₯Ό κΈ°λ‘ν•©λ‹ˆλ‹€.
  • count > 0이면, ν•΄λ‹Ή μš”μ²­ μžμ²΄μ— 따라 long query μ—¬λΆ€κ°€ κ²°μ •λ©λ‹ˆλ‹€. λ”°λΌμ„œ, key λ³΄λ‹€λŠ” count > N μ΄μ—ˆλ‹€λŠ” 질의λ₯Ό κΈ°λ‘ν•©λ‹ˆλ‹€.

@cheesecrust cheesecrust marked this pull request as ready for review October 28, 2024 04:55
lqdetect.c Outdated Show resolved Hide resolved
lqdetect.c Show resolved Hide resolved
@cheesecrust cheesecrust force-pushed the fix/do_command_dupcheck branch 3 times, most recently from 046d88c to 7a4fb9d Compare October 28, 2024 06:33
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.

리뷰 μ™„λ£Œ

lqdetect.c Outdated Show resolved Hide resolved
lqdetect.c Outdated Show resolved Hide resolved
t/long_query_detect_issue.t Show resolved Hide resolved
lqdetect.c Outdated
if (keylen > 250) {
keylen = snprintf(keybuf, sizeof(keybuf), "%.*s...%.*s", 124, key, 123, (key+(keylen - 123)));
keyptr = keybuf;
}
Copy link
Author

Choose a reason for hiding this comment

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

long key에 λŒ€ν•΄μ„œ μ €μž₯ν• λ•ŒλŠ” λ³€ν˜•λ˜μ–΄ μ €μž₯λ˜λ―€λ‘œ dupcheck ν• λ•Œλ„ long key에 λŒ€ν•΄μ„œλŠ” λ³€ν˜•λœ key λ₯Ό κΈ°μ€€μœΌλ‘œ λ³€κ²½ν•΄μ•Όν•©λ‹ˆλ‹€.
λ”°λΌμ„œ ν•΄λ‹Ή λ‘œμ§μ„ μΆ”κ°€ν•˜μ˜€μŠ΅λ‹ˆλ‹€.

Copy link
Collaborator

Choose a reason for hiding this comment

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

countκ°€ 0일 λ•Œλ§Œ μ˜λ―Έκ°€ μžˆλŠ” λ™μž‘μ΄μ£ ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

count == 0인 κ²½μš°μ—λ§Œ μ˜λ―Έκ°€ μžˆλŠ” λ™μž‘μ΄ λ§žμŠ΅λ‹ˆλ‹€.

λŒ€λž΅ μ•„λž˜μ™€ 같이 κ΅¬ν˜„ν•˜λŠ” 것이 μ’‹κ² μŠ΅λ‹ˆλ‹€.

  • do_command_dupcheck() => is_command_duplicated()
  • ν˜ΈμΆœν•˜λŠ” μͺ½μ—μ„œ do_command_dupcheck() 호좜 제거
do_lqdetect_write()
{
    if (keylen > 250) {
        keylen = snprintf(keybuf, sizeof(keybuf), "%.*s...%.*s",
                          124, key, 123, (key+(keylen - 123)));
        keyptr = keybuf;
    }
    
    if (is_command_duplicated(keyptr, keylen, cmd, arg) != true) {
        gettimeofday(&val, NULL);
        ptm = localtime(&val.tv_sec);

        . . .

        lqdetect.arg[cmd][nsaved] = *arg;
        buffer->nsaved += 1;
    }
}

t/long_query_detect_issue.t Outdated Show resolved Hide resolved
lqdetect.c Outdated
if (keylen > 250) {
keylen = snprintf(keybuf, sizeof(keybuf), "%.*s...%.*s", 124, key, 123, (key+(keylen - 123)));
keyptr = keybuf;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

countκ°€ 0일 λ•Œλ§Œ μ˜λ―Έκ°€ μžˆλŠ” λ™μž‘μ΄μ£ ?

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.

리뷰 μ™„λ£Œ

lqdetect.c Outdated Show resolved Hide resolved
lqdetect.c Outdated
if (keylen > 250) {
keylen = snprintf(keybuf, sizeof(keybuf), "%.*s...%.*s", 124, key, 123, (key+(keylen - 123)));
keyptr = keybuf;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

count == 0인 κ²½μš°μ—λ§Œ μ˜λ―Έκ°€ μžˆλŠ” λ™μž‘μ΄ λ§žμŠ΅λ‹ˆλ‹€.

λŒ€λž΅ μ•„λž˜μ™€ 같이 κ΅¬ν˜„ν•˜λŠ” 것이 μ’‹κ² μŠ΅λ‹ˆλ‹€.

  • do_command_dupcheck() => is_command_duplicated()
  • ν˜ΈμΆœν•˜λŠ” μͺ½μ—μ„œ do_command_dupcheck() 호좜 제거
do_lqdetect_write()
{
    if (keylen > 250) {
        keylen = snprintf(keybuf, sizeof(keybuf), "%.*s...%.*s",
                          124, key, 123, (key+(keylen - 123)));
        keyptr = keybuf;
    }
    
    if (is_command_duplicated(keyptr, keylen, cmd, arg) != true) {
        gettimeofday(&val, NULL);
        ptm = localtime(&val.tv_sec);

        . . .

        lqdetect.arg[cmd][nsaved] = *arg;
        buffer->nsaved += 1;
    }
}

lqdetect.c Outdated Show resolved Hide resolved
@jhpark816 jhpark816 merged commit 45d1e99 into naver:develop Oct 29, 2024
1 check passed
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.

3 participants