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

INTERNAL: Remove dummy fetch in the get API #334

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

ing-eoking
Copy link
Collaborator

@ing-eoking ing-eoking commented Jan 3, 2025

๐Ÿ”— Related Issue

โŒจ๏ธ What I did

  • ์ข…๋ฃŒ ์ง€์  ํ™•์ธ์ด ๋น„๊ต์  ์šฉ์ดํ•œ memcached_fetch_result๋ฅผ ํ™œ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค.
    • VALUE๋ฅผ ๊ฐ€์ ธ์˜ค์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ, NULL์ด ๋ฐ˜ํ™˜๋ฉ๋‹ˆ๋‹ค.
  • memcached_fetch ๋‚ด๋ถ€์—์„œ ์ฒ˜๋ฆฌํ•˜๋˜ value_length์™€ flags ์ดˆ๊ธฐํ™” ๋กœ์ง์„ memcached_get_by_key ํ•จ์ˆ˜ ์ดˆ๊ธฐ์— ์ˆ˜ํ–‰ํ•˜๋„๋ก ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.
  • ํ˜„์žฌ CentOS7 ํ™˜๊ฒฝ์—์„œ ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋Š” ๊ฒฝ์šฐ, develop ๋ธŒ๋žœ์น˜์—์„œ๋„ ๋™์ผํ•˜๊ฒŒ ์•„๋ž˜์˜ ํ…Œ์ŠคํŠธ๊ฐ€ ์‹คํŒจํ•ฉ๋‹ˆ๋‹ค.
    • ์˜ˆ์ „ mop_upsert API๋ฅผ ๊ฐœ๋ฐœํ•˜๋Š” ๊ณผ์ •์—์„œ ๋ฌธ์ œ๊ฐ€ ์žˆ์—ˆ๋˜ ๊ฒƒ์œผ๋กœ ๋ณด์ด๋ฉฐ, ์›์ธ ๋ถ„์„์ค‘์— ์žˆ์Šต๋‹ˆ๋‹ค.
    • ์ €ํฌ ์žฅ๋น„์— ์„ค์น˜๋œ memcached๊ฐ€ mop upsert๊ฐ€ ์—†๋Š” ๊ตฌ๋ฒ„์ „์ด๋ผ ์ƒ๊ธด ๋ฌธ์ œ์˜€์Šต๋‹ˆ๋‹ค.
tests/mem_functions.cc:11420: in arcus_1_10_map_upsert() Assertation  "rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED" failed, hint: CLIENT ERROR
	Testing arcus_1_10_map_upsert					[ failed ]

Copy link
Contributor

@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.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

*value_length= memcached_string_length(&result->value);
if (flags)
*flags= result->item_flags;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

memcached_fetch_result() != NULL ๊ฒฝ์šฐ๊ฐ€ 2ํšŒ ์ด์ƒ ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ๋„ ๊ณ ๋ คํ•˜์‹œ์ฃ .

This comment was marked as off-topic.

Copy link
Contributor

Choose a reason for hiding this comment

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

memcached_fetch_result() != NULL ๊ฒฝ์šฐ๊ฐ€ 2ํšŒ ์ด์ƒ ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ๋„ ๊ณ ๋ คํ•˜์‹œ์ฃ .

์˜ˆ์ „์— ์ด๋ ‡๊ฒŒ ์ฝ”๋ฉ˜ํŠธ ํ–ˆ์ง€๋งŒ, ์ด๋Ÿฌํ•œ ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ๋ณด๋Š” ๊ฒƒ์ด ๋งž๊ฒ ์ฃ ?
๋งŒ์•ฝ์˜ SW ๋ฒ„๊ทธ๋ฅผ ๊ณ ๋ คํ•˜๋”๋ผ๋„ END ์ด์ „์˜ ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  *error = ENGINE_SUCCESS;
  while (memcached_fetch_result(ptr, result, error) != NULL)
  {
    value= memcached_string_take_value(&result->value);
    if (value_length)
      *value_length= memcached_string_length(&result->value);
    if (flags)
      *flags= result->item_flags;
  }

Copy link
Contributor

Choose a reason for hiding this comment

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

while loop ์•ˆ์— ์•„๋ž˜ ์ฝ”๋“œ๊ฐ€ ์žˆ์–ด์•ผ ํ•˜์ฃ ?

if (value) 
  memcached_free(value);

if (success_occurred)
{
*error= MEMCACHED_SUCCESS;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

success_occurred ๊ฒฝ์šฐ๋Š” value != NULL ์ƒํƒœ์ž…๋‹ˆ๋‹ค.
success_occurred ๋ณ€์ˆ˜๊ฐ€ ํ•„์š” ์—†์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ , ์ด๋Ÿฌํ•œ ์ฝ”๋“œ๋Š” value == NULL ๊ฒฝ์šฐ์— ๋Œ€ํ•œ ์ฒ˜๋ฆฌ ์ฝ”๋“œ ๋‹ค์Œ์— ์œ„์น˜ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค.

Copy link
Collaborator Author

@ing-eoking ing-eoking Jan 17, 2025

Choose a reason for hiding this comment

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

value์— ๋นˆ ๋ฌธ์ž์—ด์„ ์ €์žฅํ–ˆ์„ ๊ฒฝ์šฐ, value == NULL์ด ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์šฉ์–ด๋ฅผ success_occurred์—์„œ is_value_fetched๋กœ ๋ณ€๊ฒฝํ–ˆ์Šต๋‹ˆ๋‹ค.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ing-eoking
์งˆ๋ฌธ์ž…๋‹ˆ๋‹ค.

  • value == ""(๋นˆ ๋ฌธ์ž์—ด)์„ ์ €์žฅํ•˜๊ณ  ๋‚˜์„œ, ์ด๋ฅผ ์กฐํšŒํ•˜๋ฉด ๋นˆ ๋ฌธ์ž์—ด์ด ๋ฆฌํ„ด๋˜์–ด์•ผ ํ•˜์ง€ ์•Š๋‚˜์š”?
  • value == NULL๋กœ ํ•ด์„œ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‚˜์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

result->value์—๋Š” ๋นˆ ๋ฌธ์ž์—ด์ด ๋“ค์–ด๊ฐ€๋Š”๋ฐ, ์ด๋ฅผ ๋‹ค์‹œ value์— copyํ•˜์—ฌ ๋„ฃ๋Š” ๊ณผ์ •์—์„œ NULL๋กœ ๋ณ€ํ™˜๋ฉ๋‹ˆ๋‹ค.
memcached_string_take_value ํ•จ์ˆ˜ ๋‚ด๋ถ€ ๋™์ž‘์—์„œ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๊ฐ€ 0์ด๋ฉด NULL์„ ๋ฐ˜ํ™˜ํ•˜๋„๋ก ๋˜์–ด ์žˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค

if (not memcached_string_length(string))
    return NULL;

Copy link
Contributor

Choose a reason for hiding this comment

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

value == NULL๋กœ ํ•ด์„œ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‚˜์š”?

Copy link
Collaborator Author

@ing-eoking ing-eoking Feb 19, 2025

Choose a reason for hiding this comment

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

value == NULL๋กœ ํ•ด์„œ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‚˜์š”?

๋ถˆ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. ์„œ๋ฒ„ ์ธก์—์„œ๋Š” value์— NULL ๊ฐ’์„ ์ €์žฅํ•  ์ˆ˜ ์—†์œผ๋ฉฐ,
ํด๋ผ์ด์–ธํŠธ ์ธก์—๋„ NULL Value๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๊ธฐ๋Šฅ์ด ์—†์Šต๋‹ˆ๋‹ค.

Copy link
Contributor

Choose a reason for hiding this comment

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

value = NULL, value_length = 0์œผ๋กœ ํ•˜์—ฌ set ํ•˜๋ฉด ์–ด๋–ค ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๋‚˜์š”?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

value_length๊ฐ€ 0์ด๋ฏ€๋กœ ๋นˆ๋ฌธ์ž์—ด์ด ๋“ค์–ด๊ฐ€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

memcached_set(memc, "i", 1, NULL, 0, 0, 0);
/* telnet */
get i
VALUE i 0 0

END

@jhpark816
Copy link
Contributor

@ing-eoking ์ตœ์‹ ํ™” ํ•ด ์ฃผ์„ธ์š”.

@ing-eoking ing-eoking marked this pull request as draft February 17, 2025 02:11
@ing-eoking ing-eoking force-pushed the dummy branch 4 times, most recently from 63f1421 to 887b064 Compare February 18, 2025 02:10
@ing-eoking
Copy link
Collaborator Author

@jhpark816

์ตœ์‹ ํ™” ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

@ing-eoking ing-eoking marked this pull request as ready for review February 18, 2025 02:25
Copy link
Contributor

@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.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

*value_length= memcached_string_length(&result->value);
if (flags)
*flags= result->item_flags;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

memcached_fetch_result() != NULL ๊ฒฝ์šฐ๊ฐ€ 2ํšŒ ์ด์ƒ ๋ฐœ์ƒํ•˜๋Š” ๊ฒฝ์šฐ๋„ ๊ณ ๋ คํ•˜์‹œ์ฃ .

์˜ˆ์ „์— ์ด๋ ‡๊ฒŒ ์ฝ”๋ฉ˜ํŠธ ํ–ˆ์ง€๋งŒ, ์ด๋Ÿฌํ•œ ๊ฒฝ์šฐ๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š๋Š”๋‹ค๊ณ  ๋ณด๋Š” ๊ฒƒ์ด ๋งž๊ฒ ์ฃ ?
๋งŒ์•ฝ์˜ SW ๋ฒ„๊ทธ๋ฅผ ๊ณ ๋ คํ•˜๋”๋ผ๋„ END ์ด์ „์˜ ๊ฐ€์žฅ ๋งˆ์ง€๋ง‰ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋ฉด ๋  ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  *error = ENGINE_SUCCESS;
  while (memcached_fetch_result(ptr, result, error) != NULL)
  {
    value= memcached_string_take_value(&result->value);
    if (value_length)
      *value_length= memcached_string_length(&result->value);
    if (flags)
      *flags= result->item_flags;
  }

Copy link
Contributor

@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.

๋ฆฌ๋ทฐ ์™„๋ฃŒ

*value_length= memcached_string_length(&result->value);
if (flags)
*flags= result->item_flags;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

while loop ์•ˆ์— ์•„๋ž˜ ์ฝ”๋“œ๊ฐ€ ์žˆ์–ด์•ผ ํ•˜์ฃ ?

if (value) 
  memcached_free(value);

assert_msg(ptr->query_id >= query_id +1, "Programmer error, the query_id was not incremented.");
//assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented.");

/* This is for historical reasons */
if (*error == MEMCACHED_END)
if (is_value_fetched)
Copy link
Contributor

Choose a reason for hiding this comment

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

is_value_fetched ๋ผ๋Š” ๋ณ€์ˆ˜๊ฐ€ ํ•„์š”ํ•œ๊ฐ€์š”?

์•„๋ž˜์™€ ๊ฐ™์ด ๊ฒ€์‚ฌํ•˜๋ฉด ๋˜์ง€ ์•Š๋‚˜์š”?

if (value) 

@ing-eoking
Copy link
Collaborator Author

while loop ์•ˆ์— ์•„๋ž˜ ์ฝ”๋“œ๊ฐ€ ์žˆ์–ด์•ผ ํ•˜์ฃ ?

๋ฉ”๋ชจ๋ฆฌ ํ•ด์ œ ๋กœ์ง ์ถ”๊ฐ€ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

is_value_fetched ๋ผ๋Š” ๋ณ€์ˆ˜๊ฐ€ ํ•„์š”ํ•œ๊ฐ€์š”?

success์ธ ์ƒํ™ฉ์—์„œ๋„ value๊ฐ€ NULL์ด ๋  ์ˆ˜ ์žˆ์–ด์„œ ์˜€์Šต๋‹ˆ๋‹ค.

@jhpark816 jhpark816 merged commit 5055532 into naver:develop Feb 20, 2025
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.

2 participants