Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-4546

Reactive change stream stuck after connection lost for longer than server selection timeout

    XMLWordPrintable

Details

    Description

      Summary

      When the db connection is lost for more than 30 seconds, the change stream stops emitting items and does not propagate any error. It is stuck.

      Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

      We are using the reactivestreams driver and creating a Flowable from the change stream publisher.

      The problem seems to be introduced with driver 4.3.0. Using the version before (4.2.3), the following error is received in the Flowable and it can be handled correctly (restart of the watch):

      com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27123, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message}, caused by {java.nio.channels.InterruptedByTimeoutException}}]com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27123, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadTimeoutException: Timeout while receiving message}, caused by {java.nio.channels.InterruptedByTimeoutException}}] at com.mongodb.internal.connection.BaseCluster.createTimeoutException(BaseCluster.java:413) at com.mongodb.internal.connection.BaseCluster.handleServerSelectionRequest(BaseCluster.java:314) at com.mongodb.internal.connection.BaseCluster.access$800(BaseCluster.java:62) at com.mongodb.internal.connection.BaseCluster$WaitQueueHandler.run(BaseCluster.java:484) at java.base/java.lang.Thread.run(Thread.java:833)
      

      How to Reproduce

      • Create a Flowable from a mongo watch and subscribe to it
      • Disconnect the server (e.g. shut down) and connect again after more than 30 seconds
      • Change something in the collection / db
      • Observe that neither the onError or onNext is called in the Flowable.
      • In 4.2.3, onError will be called

      Additional Background

      I tested versions up to 4.5.0 mongo driver and the issue is not fixed.

      Attachments

        Issue Links

          Activity

            People

              jeff.yemin@mongodb.com Jeffrey Yemin
              nothanks@trash-mail.com Dom S
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: