forked from bradfitz/gomemcache
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
https://github.com/daangn/x/pull/1/files#r542981077
서버 리스트가 아래와 같이 변경되는 경우에는 zombie connection이 발생할 수 있을 것 같아요.
(1, 2, 3) --> (2, 3, 4)
gomemcache 구현을 보면
- getConn() 할 때 conn을 생성하거나 pool에서 꺼내오고,
- conn.condRelease() 할 때 conn을 pool로 되돌리거나 에러가 발생했을 때 conn을 닫습니다. (maxIdleConn 도달시에도 close)
따라서 두 가지 정도의 방향으로 구현 가능할 것 같은데요...
- discoverer.updateServers() 수행 시점에 탈락한 conn에 대한 상태 flag 등을 설정하여 getConn(), condRelease() 시점에 close()
- 주기적으로 conn pool 상태를 스캔해서 zombie conn을 close 해주는 background goroutine 추가
1번은 단순해 보여서 좋긴 한데, 타이밍에 따라 놓치는 conn이 발생할 수도 있을 것 같아요. 이건 전체를 봐야 알 것 같고... 개인적으로는 명시적이고 close 타이밍을 우리가 제어할 수 있는 2번이 좋지 않을까 생각합니다.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request