Comments (5)
본 이슈가 아래 commit에서 모두 해결된 것인 지 살펴봐 주세요.
commit - 1d955ca
from arcus-c-client.
ascii protocol 일 때 quit명령으로 telnet을 종료 동작의 필요성은 이슈를 따로 생성하겠습니다.
response return에 따른 reconnect는 1d955ca 에 반영되었습니다.
- CLIENT_ERROR, PROTOCOL_ERROR, SERVER_ERROR, PARTIAL_READ에 대해 즉시 reconnect 합니다.
from arcus-c-client.
- MEMCACHED_UNKNOWN_READ_FAILURE는 delayed reconnect가 맞나요 ?
from arcus-c-client.
@jhpark816
검토해보니 MEMCACHED_UNKNOWN_READ_FAILURE는 immediate reconnect가 맞다고 봅니다.
위 에러가 발생하는 경우는
- client 가 기대하는 server response가 오지 않은 경우 : protocol 차이일 뿐이므로 immediate reconnect
- socket error(recv < 0)의 응용 오류 코드. 에를 들어 recv() 에서 EXXX 에러 발생한 경우 이를 그대로 응용에게 전달하지 않고, MEMCACHED_UNKNOWN_READ_FAILURE로 전달. 이 경우에 io 모듈단에서 delayed reconnect 하도록 되어 있음.
참고 코드:
static memcached_return_t binary_read_one_response(memcached_server_write_instance_st ptr,
char *buffer, size_t buffer_length,
memcached_result_st *result)
{
...
case PROTOCOL_BINARY_CMD_GETK:
{
..
if ((rc= memcached_safe_read(ptr, &result->item_flags, sizeof (result->item_flags))) != MEMCACHED_SUCCESS)
{
WATCHPOINT_ERROR(rc);
return MEMCACHED_UNKNOWN_READ_FAILURE;
}
memcached_return_t memcached_safe_read(memcached_server_write_instance_st ptr,
void *dta,
size_t size)
{
size_t offset= 0;
char *data= static_cast<char *>(dta);
while (offset < size)
{
ssize_t nread;
memcached_return_t rc;
// #define memcached_continue(__memcached_return_t) ((__memcached_return_t) == MEMCACHED_IN_PROGRESS)
while (memcached_continue(rc= memcached_io_read(ptr, data + offset, size - offset, &nread))) { };
if (memcached_failed(rc))
{
return rc;
}
offset+= (size_t) nread;
}
return MEMCACHED_SUCCESS;
}
memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr,
void *buffer, size_t length, ssize_t *nread)
{
assert_msg(ptr, "Programmer error, memcached_io_read() recieved an invalid memcached_server_write_instance_st"); // Programmer error
char *buffer_ptr= static_cast<char *>(buffer);
if (ptr->fd == INVALID_SOCKET)
{
//assert_msg(int(ptr->state) <= int(MEMCACHED_SERVER_STATE_ADDRINFO), "Programmer error, invalid socket state");
fprintf(stderr, "[DEBUG] invalid server state : %d, hostname : %s\n", ptr->state, ptr->hostname);
return MEMCACHED_CONNECTION_FAILURE;
}
while (length)
{
if (not ptr->read_buffer_length)
{
ssize_t data_read;
do
{
data_read= recv(ptr->fd, ptr->read_buffer, MEMCACHED_MAX_BUFFER, MSG_DONTWAIT);
if (data_read == SOCKET_ERROR)
{
switch (get_socket_errno())
{
case EINTR: // We just retry
continue;
case ETIMEDOUT: // OSX
case EWOULDBLOCK:
#ifdef USE_EAGAIN
case EAGAIN:
#endif
#ifdef TARGET_OS_LINUX
case ERESTART:
#endif
if (memcached_success(io_wait(ptr, MEM_READ)))
{
continue;
}
return MEMCACHED_IN_PROGRESS;
/* fall through */
case ENOTCONN: // Programmer Error
WATCHPOINT_ASSERT(0);
case ENOTSOCK:
WATCHPOINT_ASSERT(0);
case EBADF:
assert_msg(ptr->fd != INVALID_SOCKET, "Programmer error, invalid socket");
case EINVAL:
case EFAULT:
case ECONNREFUSED:
default:
{
//socket error : delayed reconnect
memcached_quit_server(ptr, true);
*nread= -1;
return memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT);
}
}
}
else if (data_read == 0)
{
/*
EOF. Any data received so far is incomplete
so discard it. This always reads by byte in case of TCP
and protocol enforcement happens at memcached_response()
looking for '\n'. We do not care for UDB which requests 8 bytes
at once. Generally, this means that connection went away. Since
for blocking I/O we do not return 0 and for non-blocking case
it will return EGAIN if data is not immediatly available.
*/
WATCHPOINT_STRING("We had a zero length recv()");
memcached_quit_server(ptr, true);
*nread= -1;
return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILIURE, MEMCACHED_AT);
}
} while (data_read <= 0);
...
MEMCACHED_UNKNOWN_READ_FAILURE를 immediate reconnect 하도록 변경 후 close하겠습니다.
from arcus-c-client.
아래 에러에 대해 immediate reconnect 합니다.
1d955ca
- CLIENT_ERROR, PROTOCOL_ERROR, SERVER_ERROR, PARTIAL_READ
- UNKNOWN_READ_FAILURE
from arcus-c-client.
Related Issues (20)
- __do_arcus_update_cachelist() 함수의 수행 최적화 HOT 8
- memcached_ketama_reference()와 memcached_ketama_release() 쌍의 일관성 검토. HOT 1
- memcached_st 정보의 ketama_version과 version 정보 관리의 개선 방안 검토. HOT 4
- header files을 include 하는 관계 재정리 HOT 9
- ZK 이벤트를 통한 server list와 ketama hash ring 생성 오류 처리 HOT 2
- Ketama hash ring 변경과 조회의 동시성 제어 정확성 보장. HOT 1
- master의 behavior 변경 후 pool의 멤버 mc에 적용하는 방법 개선 HOT 8
- LIBMEMCACHED_WITH_ZK_INTEGRATION 코드 태그 관리. HOT 1
- memcached_pool_update_serverlist 함수의 안정성 검증. HOT 13
- memcached_pool_update_serverlist compile 이슈. HOT 3
- memcached pool에서 master mc의 ketama hashring을 member mc가 참조 및 해제하는 방식 개선. HOT 1
- proxy 통한 cache list 변경 방식의 오류 HOT 3
- memcached_pool에 release 작업 최적화. HOT 1
- #pragma once 제거 HOT 3
- lock_arcus 사용 용도 검토 및 최적화 HOT 16
- memcached_exist_by_key() 함수에서 arcus_server_check_for_update() 함수 호출 필요성 검토 HOT 6
- pipeline 연산 API 설명 문서 수정 HOT 1
- github action을 통한 CI 도입 HOT 1
- multi-key pipelining에서 duplicate keys 검사 필요.
- core in arcus lib HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arcus-c-client.