isopov commented on issue #1884:
URL: 
https://github.com/apache/cassandra-gocql-driver/issues/1884#issuecomment-2827775527

   Similar test with java driver:
   ```
   package io.github.isopov.cassandra;
   
   import com.datastax.oss.driver.api.core.CqlSession;
   
   import java.net.InetSocketAddress;
   import java.time.Duration;
   import java.util.concurrent.ConcurrentHashMap;
   import java.util.concurrent.Executors;
   import java.util.concurrent.atomic.LongAdder;
   import java.util.random.RandomGenerator;
   
   public class Main {
   
       public static final int WORKERS = 100;
       public static final int QUERIES = 10_000;
   
   
       public static final int READ_WORKERS = 100;
       //    public static final int READ_QUERIES = 100;
       public static final int READ_QUERIES = 10_000_000;
   
       public static void main(String[] args) {
           try (var session = CqlSession.builder()
                   .addContactPoint(new InetSocketAddress("172.18.0.2", 32146))
                   //from kubectl get secret --namespace "cassandra" cassandra 
-o jsonpath="{.data.cassandra-password}" | base64 -d
                   .withAuthCredentials("cassandra", "kMDfXIiu5M")
                   .withLocalDatacenter("datacenter1")
                   .build()) {
   
               session.execute("drop keyspace if exists k8stest2");
               session.execute("create keyspace k8stest2 with replication = 
{'class' : 'SimpleStrategy', 'replication_factor' : 3}");
               session.execute("use k8stest2");
               session.execute("drop table if exists test");
               session.execute("create table test (a int, b text, primary 
key(a))");
   
               try (var executor = Executors.newVirtualThreadPerTaskExecutor()) 
{
                   for (int i = 0; i < WORKERS; i++) {
                       final var fi = i;
                       executor.submit(() -> {
                           try {
                               var query = session.prepare("insert into test 
(a, b) values (?,?)");
                               for (int j = fi * QUERIES; j < (fi + 1) * 
QUERIES; j++) {
                                   session.execute(query.bind(j, "Message" + 
j));
                               }
                           } catch (Exception e) {
                               e.printStackTrace();
                               throw e;
                           }
                       });
                   }
               }
   
               var reads = new LongAdder();
               var errors = new LongAdder();
               var errorsCount = new ConcurrentHashMap<String, Long>();
   
               try (var executor = Executors.newVirtualThreadPerTaskExecutor()) 
{
                   for (int i = 0; i < READ_WORKERS; i++) {
                       final var fi = i;
                       executor.submit(() -> {
                           RandomGenerator random = 
RandomGenerator.getDefault();
                           var query = session.prepare("select b from test 
where a=?");
                           for (int j = fi * READ_QUERIES; j < (fi + 1) * 
READ_QUERIES; j++) {
                               try {
                                   var id = random.nextInt(QUERIES * WORKERS);
                                   var res = 
session.execute(query.bind(id)).all();
                                   if (res.size() != 1) {
                                       throw new IllegalStateException("not 
read without exception");
                                   }
                                   reads.increment();
   
                               } catch (Exception e) {
                                   errors.increment();
                                   errorsCount.compute(e.getMessage(), (msg, 
count) -> {
                                       if (count == null) {
                                           return 1L;
                                       }
                                       return count + 1L;
                                   });
                                   try {
                                       Thread.sleep(Duration.ofMillis(1));
                                   } catch (InterruptedException ex) {
                                       throw new RuntimeException(ex);
                                   }
                               }
                           }
                       });
                   }
                   executor.submit(() -> {
                       while (true) {
                           Thread.sleep(Duration.ofSeconds(1));
                           System.out.println("##### " + reads + " scans, " + 
errors + " errors");
                           errorsCount.forEach((msg, count) -> {
                               System.out.println("error " + msg + " count " + 
count);
                           });
                       }
                   });
               }
           }
           System.out.println("All is done!");
       }
   }
   ```
   
   Output with removing of host during read phase
   ```
   ##### 1784 scans, 0 errors
   ##### 4260 scans, 0 errors
   ##### 6605 scans, 0 errors
   ##### 9168 scans, 0 errors
   ##### 11809 scans, 0 errors
   ...
   ##### 525279 scans, 33550 errors
   error Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99) is overloaded: 
Server is shutting down count 228
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[java.io.IOException: Connection reset by peer] count 9
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[io.netty.channel.StacklessClosedChannelException] count 1
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[com.datastax.oss.driver.api.core.NodeUnavailableException: No connection was 
available to Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99)] count 33394
   ##### 526346 scans, 95800 errors
   error Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99) is overloaded: 
Server is shutting down count 228
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[java.io.IOException: Connection reset by peer] count 9
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[io.netty.channel.StacklessClosedChannelException] count 1
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[com.datastax.oss.driver.api.core.NodeUnavailableException: No connection was 
available to Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99)] count 95562
   ##### 537125 scans, 95800 errors
   error Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99) is overloaded: 
Server is shutting down count 228
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[java.io.IOException: Connection reset by peer] count 9
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[io.netty.channel.StacklessClosedChannelException] count 1
   error All 1 node(s) tried for the query failed (showing first 1 nodes, use 
getAllErrors() for more): Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99): 
[com.datastax.oss.driver.api.core.NodeUnavailableException: No connection was 
available to Node(endPoint=/172.18.0.2:32146, 
hostId=35a8ed41-4a70-4945-9eec-53a299c03fb7, hashCode=683c0c99)] count 95562
   ##### 547382 scans, 95800 errors
   ...
   ##### 1587961 scans, 95800 errors
   ...
   ```
   After short-time period of errors during node shutdown reading continues 
gracefully during node reconnect.


-- 
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: commits-unsubscr...@cassandra.apache.org

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


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

Reply via email to