Skip to content

Possible zombie connections #2

@hoonmin

Description

@hoonmin

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)

따라서 두 가지 정도의 방향으로 구현 가능할 것 같은데요...

  1. discoverer.updateServers() 수행 시점에 탈락한 conn에 대한 상태 flag 등을 설정하여 getConn(), condRelease() 시점에 close()
  2. 주기적으로 conn pool 상태를 스캔해서 zombie conn을 close 해주는 background goroutine 추가

1번은 단순해 보여서 좋긴 한데, 타이밍에 따라 놓치는 conn이 발생할 수도 있을 것 같아요. 이건 전체를 봐야 알 것 같고... 개인적으로는 명시적이고 close 타이밍을 우리가 제어할 수 있는 2번이 좋지 않을까 생각합니다.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions