..
업무용으로 구축해 놓은 Solr 서버가
org.apache.solr.common.SolrException: Service Unavailable 와 같은 에러를 가끔씩 토해낸다.

소스 저장소에서 (http://svn.apache.org/repos/asf/lucene/solr/)
소스를 다운받아 Service Unavailable 라는 error code 를 던지는 소스를 찾아 보았더니,
아래와 같은 3가지의 경우였다.

1.
solr config 에 설정한 maxWarmingSearchers 의 갯수보다 많은 Searcher 가 열려야 하는 경우
} else if (onDeckSearchers > maxWarmingSearchers) {
        onDeckSearchers--;
        String msg="Error opening new searcher. exceeded limit of maxWarmingSearchers="+maxWarmingSearchers + ", try again later.";
        log.warn(logid+""+ msg);
        // HTTP 503==service unavailable, or 409==Conflict
        throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,msg,true);

2.
solr 서버의 상태가 맛이 간(?) 경우
String healthcheck = core.getSolrConfig().get("admin/healthcheck/text()", null );
    if( healthcheck != null && !new File(healthcheck).exists() ) {
      throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE, "Service disabled", true);
    }

3.
post 로 쿼리를 전송했을 때, 결과 값을 받지 못했을 때
private NamedList getNamedListResponse(PostMethod method) throws IOException {
    try {
      int status = myHttpClient.executeMethod(method);
      if (status != HttpStatus.SC_OK) {
        throw new SolrException(SolrException.ErrorCode.SERVICE_UNAVAILABLE,
                "Request failed for the url " + method);
      }
      return (NamedList) new JavaBinCodec().unmarshal(method.getResponseBodyAsStream());
    } finally {
      try {
        method.releaseConnection();
      } catch (Exception e) {
      }
    }
  }
저작자 표시
Posted by utsman 트랙백 0 : 댓글 0