Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-15 Thread via GitHub


kotman12 commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6180745859

   > @epugh did you squash-merge this by accident? Luke is a committer. I 
noticed the commit message was blank. I suggest the practice of copying the 
changelog text _at a minimum_.
   
   There's a story behind this ... I agree with you, David. We will do better 
next time.


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-14 Thread via GitHub


dsmiley commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6180230625

   @epugh did you squash-merge this by accident?  Luke is a committer.
   I noticed the commit message was blank.  I suggest the practice of copying 
the changelog text _at a minimum_.


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-14 Thread via GitHub


epugh merged PR #4974:
URL: https://github.com/apache/solr/pull/4974


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-13 Thread via GitHub


kotman12 commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6147097058

   I plan on merging this in the next couple of days.


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-09 Thread via GitHub


kotman12 commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6093070024

   @dsmiley sorry for the spam but I realized I was referring to 
[SOLR-17916](https://issues.apache.org/jira/browse/SOLR-17916)
   
   Seems like this is the "latest" reason we don't abort and I just assumed 
that was what you linked.


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-09 Thread via GitHub


kotman12 commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6092837163

   > I didn't have a specific approach in mind to make it adjunct; it wasn't an 
entirely thought-out idea.
   > 
   > This issue is related to #3428 / #3695 . If it gets reverted, then that 
provides a way for a client who uses the async API to abort the requests it 
sends without aborting the entire client.
   
   And the problem of course with aborting sync requests (instead of the entire 
client) is that you don't have an easy way to propagate to the request from the 
call site. I figured aborting the client is ok to do for IF. Though I can see 
if we can do it another way. I just figured the client is lightweight and IF 
isn't a very tight loop 


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-09 Thread via GitHub


kotman12 commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6092786097

   > I didn't have a specific approach in mind to make it adjunct; it wasn't an 
entirely thought-out idea.
   > 
   > This issue is related to #3428 which should probably be reverted now. If 
it gets reverted, then that provides a way for a client who exclusively uses 
the async API to abort the requests it send without aborting the entire client.
   
   Yes I did see that issue when developing this. It's a bit frustrating to 
have to work around http/2 issues (again). Seems that this stream reset circuit 
breaker is really only a problem with http/2. Claude had an idea to schedule 
the aborts on future cancel with a small delay so most completed before sending 
the reset to the rest (I think the issue in the linked PR was that there are 
too many resets too close in time).
   
   I actually almost went the async route with this PR. 
   That being said I think its more natural to leave IF sync and I see no 
reason to not have cancelability on sync calls as well. I initially reached for 
the async API only because it _seemed_ like the intended cancellable mode the 
http jetty solr client supported (until I found cancellation wasn't propagated 
due to the above 😬). But it required a conversion layer to sync which was quite 
ugly.
   
   I support undoing the change you cite though I don't think it is directly 
related to this change anymore. Also, I dont want to introduce the reset 
overload issue again so we'd have to see what works regarding that.


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-09 Thread via GitHub


dsmiley commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6092461864

   I didn't have a specific approach in mind to make it adjunct; it wasn't an 
entirely thought-out idea.
   
   This issue is related to #3428 which should probably be reverted now.  If it 
gets reverted, then that provides a way for a client who exclusively uses the 
async API to abort the requests it send without aborting the entire client.


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-09 Thread via GitHub


kotman12 commented on PR #4974:
URL: https://github.com/apache/solr/pull/4974#issuecomment-6088797597

   > Excellent work Luke!
   > 
   > My only reservation is wether this belongs directly on HttpJettySolrClient 
or could be a adjunct in some way for use only within Solr. But I saw the code 
comment about wanting to ensure the async callbacks happen with the abort 
callback in a way we control, so that basically rules out decoupling. That's 
fine. It overall is rather light-weight, any way.
   
   Thanks David! 
   
   Re making this a "private adjunct":
   
   This is an excellent question! I'll start with that I don't agree it 
_should_ be an "adjunct" for internal use only (btw I am assuming internal 
"adjunct" means a custom listener factory you simply pass in, correct me if I 
am mischaracterizing your idea). I think `abort`/`isAborted` is a natural API 
to have. Most HTTP clients have some form of it so why make life difficult for 
solrj users (such as ourselves 😃)? Perhaps you were also suggesting that 
external  users that need to abort could write their own custom abort listeners 
for the same effect?
   
   All that being said it is technically possible, even with the permit 
tracking dilemma. You'd just have to make the `AsyncTracker` listener a special 
case that is guaranteed to be invoked before (for both the `onQueued` and 
`onComplete` cases) your custom private listeners. What makes it awkward is 
that the existing listeners expect onQueued to be fired from the request-making 
thread and not from the callback (really confusing). So you'd have to 
disambiguate the new interface somehow.
   
   But the most interesting thing is this raises the problem of listener 
factory sharing:
   
   ```
   public Builder withHttpClient(HttpJettySolrClient httpJettySolrClient) {
 super.withHttpClient(httpJettySolrClient);
 this.httpClient = httpJettySolrClient.httpClient;
   
 if (this.idleTimeoutMillis == null) {
   this.idleTimeoutMillis = httpJettySolrClient.idleTimeoutMillis;
 }
 if (this.listenerFactories == null) {
   this.listenerFactories = httpJettySolrClient.listenerFactory;
 }
 if (this.executor == null) {
   this.executor = httpJettySolrClient.executor;
 }
 return this;
   }
   ``` 
   
   If your request tracking "adjunct" (which I, again, assume is a listener 
factory) gets added to a listener factory list then it will incidentally get 
added to all http clients that are in its "copy-tree". Perhaps this should be a 
copy-on write? Should we make this a separate ticket?
   
   Btw, If we are really paranoid about backwards compatibility we could mark 
it as `@lucene.experimental` though not sure how big of a concern that even is. 
Worst case it moves to a no-op if somehow Jetty yanks the underlying hook 
(though I highly doubt it).
   
   


-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-08 Thread via GitHub


dsmiley commented on code in PR #4974:
URL: https://github.com/apache/solr/pull/4974#discussion_r4221344657


##
changelog/unreleased/SOLR-18480-abort-fetcher.yml:
##
@@ -0,0 +1,10 @@
+title: >-

Review Comment:
   I think the changelog could add a sentence to speak of this nice new abort 
feature of HttpJettySolrClient.



-- 
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]



Re: [PR] SOLR-18480 prevent TLOG+PULL leader election stall by aborting fetcher [solr]

2026-10-01 Thread via GitHub


kotman12 commented on code in PR #4974:
URL: https://github.com/apache/solr/pull/4974#discussion_r4160146726


##
solr/core/src/test/org/apache/solr/cloud/TlogLeaderElectionFrozenLeaderTest.java:
##
@@ -0,0 +1,343 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.cloud;
+
+import com.carrotsearch.randomizedtesting.annotations.Name;
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import jakarta.servlet.Filter;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.ServletRequest;
+import jakarta.servlet.ServletResponse;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.servlet.http.HttpServletResponseWrapper;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.lang.invoke.MethodHandles;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.util.SuppressForbidden;
+import org.apache.solr.embedded.JettySolrRunner;
+import org.apache.solr.handler.ReplicationHandler;
+import org.apache.solr.servlet.ServletOutputStreamWrapper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Reproduces a TLOG leader election that stalls because the outgoing leader 
froze rather than died.
+ *
+ * {@link ShardLeaderElectionContext#runLeaderProcess} calls {@link
+ * ZkController#stopReplicationFromLeader} inline on the election thread. That 
tears down the
+ * follower's replication process, which blocks in {@code 
ExecutorUtil.shutdownAndAwaitTermination}
+ * until the in-flight index fetch finishes. {@code IndexFetcher.abortFetch} 
only sets a flag that
+ * is polled while streaming file packets, so a fetch parked in the network 
phase is not cut short:
+ * the election parks for the 60s executor wait before {@code shutdownNow()} 
finally interrupts the
+ * poll thread.
+ */
+public class TlogLeaderElectionFrozenLeaderTest extends SolrCloudTestCase {
+
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  private static final String COLLECTION = "tlog_frozen_leader";
+  private static final String SHARD = "shard1";
+
+  /**
+   * A replacement election sleeps a fixed 2.5s for in-flight updates to settle
+   * (ShardLeaderElectionContext), then syncs, replays its tlog and publishes 
in well under a
+   * second. The bug parks it for the 60s {@code 
ExecutorUtil.awaitTermination} wait instead.
+   */
+  private static final long MAX_ACCEPTABLE_ELECTION_MS = 10_000;
+
+  /** How long to wait for the follower's next poll to reach the stalled 
leader. */
+  private static final long STALL_ARRIVAL_TIMEOUT_MS = 30_000;
+
+  /** Where a follower's fetch can park against a frozen leader. */
+  public enum TestStallPoint {

Review Comment:
   There are several possible I/O stall points between new and former leader. 
To be thorough I test all in the nightly build.



##
solr/core/src/java/org/apache/solr/handler/IndexFetcher.java:
##
@@ -1666,11 +1710,6 @@ private int fetchPackets(FastInputStream fis) throws 
Exception {
 }
 return 0;
   }
-  if (stop) {
-stop = false;

Review Comment:
   This is a vestige from when individual fetch abortion was tracked at the 
`IndexFetcher` level (kind of strange). Now aborting a fetch only aborts the 
fetch-scoped client and that gets discarded in the `finally` block of 
`fetchLatestIndex` so the scope is more cleanly enforced.



##
solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java:
##
@@