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

sop exist 연산에서 NOT_EXIST 시에 응답 검토 #181

Open
SuhwanJang opened this issue Dec 2, 2021 · 2 comments
Open

sop exist 연산에서 NOT_EXIST 시에 응답 검토 #181

SuhwanJang opened this issue Dec 2, 2021 · 2 comments
Assignees
Labels

Comments

@SuhwanJang
Copy link

SuhwanJang commented Dec 2, 2021

sop exist 연산에서 NOT_EXIST 시에 응답이 실제 코드와 가이드 문서에 차이가 있다.

코드 : NOT_EXIST 시 NOT_EXIST 리턴

 static memcached_return_t do_coll_exist(memcached_st *ptr,
                                         const char *key, size_t key_length,
                                         const char *value, size_t value_length,
                                         memcached_coll_action_t verb)
 {
   rc= memcached_vdo(instance, vector, 5, to_write);

   if (rc == MEMCACHED_SUCCESS)
   {
     if (to_write == false)
     {
       rc= MEMCACHED_BUFFERED;
     }
     else if (ptr->flags.no_reply)
     {
       rc= MEMCACHED_SUCCESS;
     }
     else
     {
       char result[MEMCACHED_DEFAULT_COMMAND_SIZE];
       rc= memcached_coll_response(instance, result, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL);

       if (rc == MEMCACHED_EXIST)
       {
         rc= MEMCACHED_SUCCESS;
       }
     }
   }

   if (rc == MEMCACHED_WRITE_FAILURE)
   {
     memcached_io_reset(instance);
   }

   return rc;
 }

가이드문서 : NOT_EXIST 인 경우에 SUCCESS 응답을 기대
https://github.com/naver/arcus-c-client/blob/master/docs/05-set-API.md

void arcus_set_element_exist(memcached_st *memc)
{
    uint32_t flags= 10;
    uint32_t exptime= 600;
    uint32_t maxcount= 1000;

    memcached_coll_create_attrs_st attributes;
    memcached_coll_create_attrs_init(&attributes, flags, exptime, maxcount);

    memcached_return_t rc;

    // 테스트 데이터를 입력한다.
    rc= memcached_sop_insert(memc, "set:a_set", strlen("set:a_set"),
                             "value", strlen("value"), &attributes);
    assert(MEMCACHED_SUCCESS == rc);
    assert(MEMCACHED_CREATED_STORED == memcached_get_last_response_code(memc));

    // 요청한 데이터가 존재하는 않는 경우
    rc= memcached_sop_exist(memc, "set:a_set", strlen("set:a_set"),
                            "no value", strlen("no value"));
    assert(MEMCACHED_SUCCESS == rc);
    assert(MEMCACHED_NOT_EXIST == memcached_get_last_response_code(memc));

    // 요청한 데이터가 존재하는 경우
    rc= memcached_sop_exist(memc, "set:a_set", strlen("set:a_set"),
                            "value", strlen("value"));
    assert(MEMCACHED_SUCCESS == rc);
    assert(MEMCACHED_EXIST == memcached_get_last_response_code(memc));
}
  • 가이드문서와 같이 정의하는 것이 다른 연산들과 같은 형태로 자연스러운 것 같긴 합니다.
  • backward compatiablity 문제는
    • 응용이 last_response_code 를 통해 NOT_EXIST 처리를 해두었다면 현재 코드를 수정해도 문제되지 않습니다.
    • last_response_code 가 아닌 rc 로 NOT_EXIST 처리를 한다면 현재와 같이 NOT_EXIST 응답을 주어야 되므로 가이드 문서를 수정해야 합니다.
@SuhwanJang SuhwanJang self-assigned this Dec 2, 2021
@jhpark816
Copy link
Contributor

@SuhwanJang

  • 현재 API와 DOC는 서로 일치하지 않는 상태이고, 어느 한 쪽으로 맞추기는 해야 합니다.
  • Backward compatibility 이슈가 되는 지를 알기 위해, 아래 확인해야 합니다.
    • c client 사용하는 클러스터 확인
    • sop exist 명령 사용 여부 확인
  • Backward compatibility 조사를 도와주는 도구가 있으면 좋을 것 같습니다.
    • ZK ensemble 목록을 주면 c client 사용하는 클러스터 목록 확인하는 도구
    • 클러스터 목록과 특정 연산을 주면, 그 연산을 요청하는 클러스터 확인하는 도구

@jhpark816 jhpark816 assigned namsic and ing-eoking and unassigned SuhwanJang and namsic Feb 8, 2024
@ing-eoking
Copy link
Collaborator

ing-eoking commented Mar 21, 2024

@jhpark816

가이드문서 : NOT_EXIST 인 경우에 SUCCESS 응답을 기대

자연스러운 코드 형식으로는 문서를 따라 고치는게 맞다고 생각됩니다.
하지만 만약 완전히 Backward compatibility를 고려해야 한다면, 오히려 문서를 수정하는 게 맞지 않나 생각됩니다.

backward compatibility 문제는
응용이 last_response_code 를 통해 NOT_EXIST 처리를 해두었다면 현재 코드를 수정해도 문제되지 않습니다.
last_response_code 가 아닌 rc 로 NOT_EXIST 처리를 한다면 현재와 같이 NOT_EXIST 응답을 주어야 되므로 가이드 문서를 수정해야 합니다.

사용자가 문서가 안내하고 있는 상황을 그대로 따를시 assert가 되게 유도됩니다.
만약 아직 C Client를 사용하고 있고, Sop exist를 사용 중인 사용자라면 문서를 따르지 않고, 아래의 형태를 따르고 있지 않을까 생각됩니다.

// 요청한 데이터가 존재하는 않는 경우
    rc= memcached_sop_exist(memc, "set:a_set", strlen("set:a_set"),
                            "no value", strlen("no value"));
    assert(MEMCACHED_NOT_EXIST == rc);
    assert(MEMCACHED_NOT_EXIST == memcached_get_last_response_code(memc));

Backward compatibility 조사를 도와주는 도구가 있으면 좋을 것 같습니다.

  • ZK ensemble 목록을 주면 c client 사용하는 클러스터 목록 확인하는 도구
  • 클러스터 목록과 특정 연산을 주면, 그 연산을 요청하는 클러스터 확인하는 도구

이거는 원격에서 zk ensemble에서 client list를 조회하여, 해당 클라이언트가 c client를 사용하는지 확인하는 도구인가요?
지금으로서는 가능해보이는 방안은 떠오르진 않습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants