HoustonPutman commented on code in PR #4774:
URL: https://github.com/apache/solr/pull/4774#discussion_r3866967511


##########
solr/solrj-zookeeper/src/java/org/apache/solr/common/cloud/OnReconnect.java:
##########
@@ -26,14 +29,36 @@
  * implementation should call
  * org.apache.solr.cloud.ZkController#removeOnReconnectListener(OnReconnect) 
when it no longer needs
  * to be notified of ZK reconnection events.
+ *
+ * <p>When registered as a Curator {@link ConnectionStateListener}, {@link 
#onReconnect()} runs only
+ * after a session expiration ({@link ConnectionState#LOST} then {@link
+ * ConnectionState#RECONNECTED}). A reconnect after {@link 
ConnectionState#SUSPENDED} keeps the
+ * ZooKeeper session and must not trigger SolrCloud recovery. See SOLR-18298.
  */
 public interface OnReconnect extends ConnectionStateListener {
   void onReconnect();
 
   @Override
   default void stateChanged(CuratorFramework client, ConnectionState newState) 
{
-    if (ConnectionState.RECONNECTED.equals(newState)) {
+    if (newState == ConnectionState.LOST) {
+      LostSessions.mark(this);
+    } else if (newState == ConnectionState.RECONNECTED && 
LostSessions.consume(this)) {
       onReconnect();
     }
   }
+
+  /** Tracks listeners that have observed {@link ConnectionState#LOST} and 
still need reconnect. */
+  final class LostSessions {

Review Comment:
   I would really rather have an atomic boolean in ZkController and 
ZkStateReader that maintains this. It will eventually go away.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to