joao-r-reis commented on code in PR #1875:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1875#discussion_r2079857332


##########
query_executor.go:
##########
@@ -89,14 +89,18 @@ func (q *queryExecutor) executeQuery(qry ExecutableQuery) 
(*Iter, error) {
        // check if the host id is specified for the query,
        // if it is, the query should be executed at the corresponding host.
        if hostID := qry.GetHostID(); hostID != "" {
+               pool, ok := q.pool.getPoolByHostID(hostID)
+               if !ok || !pool.host.IsUp() {
+                       return nil, ErrNoConnections
+               }
+               host := pool.host
                hostIter = func() SelectedHost {
-                       pool, ok := q.pool.getPoolByHostID(hostID)
-                       // if the specified host is down
-                       // we return nil to avoid endless query execution in 
queryExecutor.do()
-                       if !ok || !pool.host.IsUp() {
-                               return nil
+                       if host != nil {

Review Comment:
   To ensure this `hostIter` can be safely called concurrently I think we 
should make the outer variable an `int` and then use `atomic.CompareAndSwap` in 
this `if`
   
   ```
                returnedHostOnce := 0
                hostIter = func() SelectedHost {
                        if atomic.CompareAndSwapInt32(&returnedHostOnce, 0, 1) {
                               return return (*selectedHost)(host)
                           }
                           return nil
                   }
   ```



##########
query_executor.go:
##########
@@ -89,14 +89,18 @@ func (q *queryExecutor) executeQuery(qry ExecutableQuery) 
(*Iter, error) {
        // check if the host id is specified for the query,
        // if it is, the query should be executed at the corresponding host.
        if hostID := qry.GetHostID(); hostID != "" {
+               pool, ok := q.pool.getPoolByHostID(hostID)
+               if !ok || !pool.host.IsUp() {

Review Comment:
   I don't think we need this now that we return `nil` after the first 
execution since this check is already being done in the query executor. We 
needed this before because we needed a way to prevent the `hostIter` from 
returning the same unresponsive host over and over again.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to