jasonstack commented on code in PR #3350:
URL: https://github.com/apache/cassandra/pull/3350#discussion_r1685207373
##########
src/java/org/apache/cassandra/index/IndexStatusManager.java:
##########
@@ -84,26 +85,39 @@ private IndexStatusManager()
*/
public <E extends Endpoints<E>> E filterForQuery(E liveEndpoints, Keyspace
keyspace, Index.QueryPlan indexQueryPlan, ConsistencyLevel level)
Review Comment:
The next call after `filterForQuery` is to filter for EACH_QUOUM in
`ReplicaPlans#contactForRead`. If 1st DC has 3 succeeded replicas and 2nd DC
has 3 unknown repliacs. `filterForQuery` will return 3 succeeded + 1 unknown
and will fail the consistency requirement for `EACH_QUOUM`. Not sure if we care
about EACH_QUOUM for indexes.
The safest approach here is to sort replicas by query status. How about
following?
```
Set<Replica> queryableNonSucceeded = new
HashSet<>(liveEndpoints.size());
E queryableEndpoints = liveEndpoints.filter(replica -> {
boolean allBuilt = true;
for (Index index : indexQueryPlan.getIndexes())
{
Index.Status status = getIndexStatus(replica.endpoint(),
keyspace.getName(), index.getIndexMetadata().name);
if (!index.isQueryable(status))
return false;
if (status != Index.Status.BUILD_SUCCEEDED)
allBuilt = false;
}
if (!allBuilt)
queryableNonSucceeded.add(replica);
return true;
});
// deprioritize replica with queryable but non-succeeded state
if (!queryableNonSucceeded.isEmpty())
queryableEndpoints =
queryableEndpoints.sorted(Comparator.comparingInt(r ->
queryableNonSucceeded.contains(r) ? 1 : -1));
```
--
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]