-
Notifications
You must be signed in to change notification settings - Fork 55
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
INTERNAL: Limit the count of elems get from set structure #826
base: develop
Are you sure you want to change the base?
Conversation
์์ ์ฌํญ์ ๊ดํ ์ฝ๋๋ฅผ ๋ณด์ฌ์ฃผ์ธ์. |
bool delete = false;
bool drop_if_empty = false;
uint32_t count = 0;
if (! safe_strtoul(tokens[SOP_KEY_TOKEN+1].value, &count)) {
print_invalid_command(c, tokens, ntokens);
out_string(c, "CLIENT_ERROR bad command line format");
return;
}
+ if (count > MAX_SGET_ELM_COUNT) {
+ out_string(c, "CLIENT_ERROR bad value");
+ return;
+ }
if (ntokens == 6) {
if (strcmp(tokens[SOP_KEY_TOKEN+2].value, "delete")==0) {
delete = true;
} else if (strcmp(tokens[SOP_KEY_TOKEN+2].value, "drop")==0) {
delete = true;
drop_if_empty = true;
} else {
print_invalid_command(c, tokens, ntokens);
out_string(c, "CLIENT_ERROR bad command line format");
return;
}
}
process_sop_get(c, key, nkey, count, delete, drop_if_empty); ์ด ๊ฒฝ์ฐ, ์ ๋ํ
์คํธ assert_sop_get("skey 50000", $flags, 50000, 0, 49999); /* fail */
assert_sop_get("skey 0", $flags, 50000, 0, 49999); /* success */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sop get skey 50000
๊ณผ sop get skey 0
์ด ์์ง ๋ด๋ถ์์๋ ๋์ผํ ์ ์ฒด ์กฐํ ์์ฒญ์ด๋ผ๊ณ ํ๋๋ผ๋
ํด๋ผ์ด์ธํธ ์
์ฅ์์๋ ์ ์ฒด elem ๊ฐ์๋ฅผ ๋ช
ํํ ์ ์ ์๋ ๊ฒ์ด ์๋๊ธฐ ๋๋ฌธ์ ๋ ์์ฒญ์๋ ์๋ฏธ ์ ์ฐจ์ด๊ฐ ์๋ค๊ณ ๋ณผ ์ ์์ต๋๋ค.
๋ฐ๋ผ์ sop get skey 50000
์ ์คํจํ๊ณ sop get skey 0
์ ์ฑ๊ณตํ๋ ๊ฒ์ด ํน๋ณํ ์ด์ํด๋ณด์ด์ง๋ ์๋๋ฐ์.
ํ
์คํธ๋ฅผ ์์ ํ๋ ํธ์ด ์คํ๋ ค ์์ฐ์ค๋ฌ์ด ๋ฐฉํฅ์ผ๋ก ๋ณด์
๋๋ค.
์ฐ์ ์์ ๋์์ต๋๋ค. ์๋๋ ์ง๋ฌธ์ฌํญ ์ ๋๋ค.
ํด๋ผ์ด์ธํธ์์ ํ์ฌ sop get์ max_count๋ฅผ ์ด๊ณผํ๋ ๊ฐ๋ ์ฑ๊ณตํ๊ฒ ๋ ๋์ด์์ต๋๋ค. |
element๊ฐ ์ถ๊ฐ๋๊ฑฐ๋ ์ ๊ฑฐ๋๋ set item์ด ์์ ๋, ๊ฐ์ ๋ช ๋ น์ด ์ด๋จ ๋๋ ์ฑ๊ณตํ๊ณ ์ด๋จ ๋๋ ์คํจํ๋ ๊ฒ์ด ์ง๊ด์ ์ด์ง ์์ต๋๋ค.
์์ง ๊ตฌํ์ฒด์ ํน์ฑ์ด๋ ์ฒ๋ฆฌ ๋ฅ๋ ฅ์ ๋ฐ๋ผ count ์ ์ฝ์ด ๋ฌ๋ผ์ง ์ ์๋ค๋ฉด ์์ง ๋ด๋ถ์์ ์ฒ๋ฆฌํ๋ ๊ฒ์ด ์์ฐ์ค๋ฌ์ธ ์ ์์ต๋๋ค. |
memcached.h
Outdated
@@ -84,6 +84,7 @@ | |||
#define BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t)) | |||
|
|||
#define MAX_MGET_KEY_COUNT 10000 | |||
#define MAX_SGET_ELM_COUNT 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํน๋ณํ ๋ณ๊ฒฝ ์์ด๋์ด๊ฐ ์๋ ๊ฒ์ ์๋๊ณ , ์ฐธ๊ณ ์ฌํญ์ผ๋ก ๊ฐ์ธ ์๊ฒฌ ๊ณต์ ํฉ๋๋ค.
โฆMGET_โฆ
๊ณผ โฆSGET_
์ด ๋ถ์ด์๋ค๋ณด๋ ์ค์น๋ฏ ๋ณด์์ ๋
SGET
=> single get
๋๋ MGET
=> mop get
๊ณผ ๊ฐ์ด ์ฐฉ๊ฐํ ์ ์์ด ๋ณด์
๋๋ค.
ํ์ง๋ง MAX_BMGET_ELM_COUNT
๊ณผ ๊ฐ์ ๊ธฐ์กด ์์ ์ด๋ฆ์ ๋ณผ ๋,
ํ์ฌ PR์ ์์๋ช
์ด ์ผ๊ด์ฑ์ ํด์น์ง ์๋๋ค๋ ์ ์์๋ ์ ์ ํ๊ณ ,
๊ด๋ จ ์ฝ๋๋ฅผ ํ์ธํ ๋ ๋ฌธ์ ๊ฐ ์๊ธธ ์ ๋๋ ์๋ ๊ฒ์
๋๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฉ์ด ๋ณ๊ฒฝํฉ์๋ค.
- MAX_SGET_ELM_COUNT => MAX_SOP_GET_COUNT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๋ฆฌ๋ทฐ ์๋ฃ
memcached.h
Outdated
@@ -84,6 +84,7 @@ | |||
#define BIN_PKT_HDR_WORDS (MIN_BIN_PKT_LENGTH/sizeof(uint32_t)) | |||
|
|||
#define MAX_MGET_KEY_COUNT 10000 | |||
#define MAX_SGET_ELM_COUNT 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ฉ์ด ๋ณ๊ฒฝํฉ์๋ค.
- MAX_SGET_ELM_COUNT => MAX_SOP_GET_COUNT
@@ -10950,6 +10950,10 @@ static void process_sop_command(conn *c, token_t *tokens, const size_t ntokens) | |||
out_string(c, "CLIENT_ERROR bad command line format"); | |||
return; | |||
} | |||
if (count > MAX_SGET_ELM_COUNT) { | |||
out_string(c, "CLIENT_ERROR bad value"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CLIENT_ERROR๊ฐ ์๋ ๋ค๋ฅธ ์๋ต ๋ฌธ์์ด์ ์ด๋ค ๊ฒ์ด ์๋์?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sop get์ ๊ฒฝ์ฐ ์๋์ ์๋ฌ๊ฐ ๋ฐํ๋ฉ๋๋ค.
Response String | ์ค๋ช |
---|---|
"NOT_FOUND" | key miss |
"NOT_FOUND_ELEMENT" | element miss (element๊ฐ ์กด์ฌํ์ง ์๋ ์ํ์) |
"TYPE_MISMATCH" | ํด๋น item์ด set collection์ด ์๋ |
"UNREADABLE" | ํด๋น item์ด unreadable item์ |
"NOT_SUPPORTED" | ์ง์ํ์ง ์์ |
"CLIENT_ERROR bad command line format" | protocol syntax ํ๋ฆผ |
"SERVER_ERROR out of memory [writing get response]" | ๋ฉ๋ชจ๋ฆฌ ๋ถ์กฑ |
@@ -1,7 +1,7 @@ | |||
#!/usr/bin/perl | |||
|
|||
use strict; | |||
use Test::More tests => 83007; | |||
use Test::More tests => 83005; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ํ ์คํธ๋ ๋ณ๊ฒฝํด์ผ ๊ฒ ์ง๋ง, docs๋ ํจ๊ป ๋ณ๊ฒฝํฉ์๋ค.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ ๋์์ต๋๋ค.
๐ Related Issue
โจ๏ธ What I did
sop get
์ฐ์ฐ์์ ์ผ๋ถ element ์กฐํ ์ ๊ฐ๋ฅํ ๊ฐ์๋ฅผ 1000๊ฐ๋ก ์ ํํฉ๋๋ค.์ฒ์์๋ core(memcached.c)์์ 1000๊ฐ ์ดํ๋ก ์กฐํ ๊ฐ์๋ฅผ ์ ํํ๊ณ ์๋ฌ ๋ฉ์์ง๋ฅผ ๋ฐํํ์ผ๋,
์ด ๊ฒฝ์ฐ, count๊ฐ 1000์ ์ด๊ณผํ๋ set์ ๋ํด ์ ์ฒด ์กฐํ๊ฐ ๋ถ๊ฐ๋ฅํ์ต๋๋ค.
๊ทธ๋์ ํ์ฌ PR์ count ์ ๋ณด๋ฅผ ๊ฐ์ง ์์ง์์ ์ ํ์ ์ ์ฉํ๊ณ ์์ต๋๋ค.