adelapena commented on code in PR #1804:
URL: https://github.com/apache/cassandra/pull/1804#discussion_r958581524


##########
src/java/org/apache/cassandra/schema/MigrationCoordinator.java:
##########
@@ -369,22 +418,31 @@ private synchronized boolean 
shouldApplySchemaFor(VersionInfo info)
 
     synchronized Future<Void> reportEndpointVersion(InetAddressAndPort 
endpoint, UUID version)
     {
+        logger.debug("Reported schema {} at endpoint {}", version, endpoint);
         if (ignoredEndpoints.contains(endpoint) || 
IGNORED_VERSIONS.contains(version))
         {
             endpointVersions.remove(endpoint);
             removeEndpointFromVersion(endpoint, null);
+            logger.debug("Discarding endpoint {} or schema {} because either 
endpoint or schema version were marked as ignored", endpoint, version);
             return FINISHED_FUTURE;
         }
 
         UUID current = endpointVersions.put(endpoint, version);
         if (current != null && current.equals(version))
+        {
+            logger.trace("Skipping report of schema {} from {} because we 
already know that", version, endpoint);
             return FINISHED_FUTURE;
+        }
 
         VersionInfo info = versionInfo.computeIfAbsent(version, 
VersionInfo::new);
         if (Objects.equals(schemaVersion.get(), version))
+        {
             info.markReceived();
+            logger.trace("Schema {} from {} has been marked as recevied 
because it is equal the local schema", version, endpoint);
+        }
         info.endpoints.add(endpoint);
-        info.requestQueue.addFirst(endpoint);
+        info.requestQueue.addFirst(endpoint); // TODO not sure if it is 
correct - given we've just marked this schema version as received, why do we 
add a request to receive it?

Review Comment:
   So we add it to `requestQueue` because we might need to fetch it, unless it 
has been marked as received. I guess the simplified version would be adding the 
endpoint to the request queue only if hasn't been marked, something like:
   ```java
   VersionInfo info = versionInfo.computeIfAbsent(version, VersionInfo::new);
   info.endpoints.add(endpoint);
   logger.trace("Added endpoint {} to schema {}: {}", endpoint, info.version, 
info);
   
   if (Objects.equals(schemaVersion.get(), version))
   {
       info.markReceived();
       logger.trace("Schema {} from {} has been marked as received because it 
is equal the local schema", version, endpoint);
   }
   else
   {
       info.requestQueue.addFirst(endpoint);
   }
   ```



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