소스 검색

query executor: better handling of errors for host selection

We cannot mark the host as failed in case of logical errors, whether it is from
gocql itself or from the context package.
Thomas Meson 6 년 전
부모
커밋
d9b5b8c364
1개의 변경된 파일9개의 추가작업 그리고 1개의 파일을 삭제
  1. 9 1
      query_executor.go

+ 9 - 1
query_executor.go

@@ -112,7 +112,15 @@ func (q *queryExecutor) do(ctx context.Context, qry ExecutableQuery) *Iter {
 		iter = q.attemptQuery(ctx, qry, conn)
 		iter.host = selectedHost.Info()
 		// Update host
-		selectedHost.Mark(iter.err)
+		switch iter.err {
+		case context.Canceled, context.DeadlineExceeded, ErrNotFound:
+			// those errors represents logical errors, they should not count
+			// toward removing a node from the pool
+			selectedHost.Mark(nil)
+			return iter
+		default:
+			selectedHost.Mark(iter.err)
+		}
 
 		// Exit if the query was successful
 		// or no retry policy defined or retry attempts were reached