bereng commented on a change in pull request #870:
URL: https://github.com/apache/cassandra/pull/870#discussion_r573472792



##########
File path: 
test/unit/org/apache/cassandra/cql3/validation/operations/AlterTest.java
##########
@@ -269,6 +276,63 @@ public void testCreateAlterKeyspaces() throws Throwable
                                   "max_threshold", "32")));
     }
 
+    @Test
+    public void testCreateAlterKeyspacesRFWarnings() throws Throwable
+    {
+        requireNetwork();
+        Thread.sleep(1000); // Hack: requireNetwork() will clear warnings 
async so give some time to complete

Review comment:
       Hi,
   
   Thx Andres for multiplexing it but running the method individually won't 
repro the issue. I get it, sometimes, only if running the whole class. It 
failed only 1 out of 20 for me today whereas it used to fail every time some 
days ago...
   
   As I am failing to explain why the polling is wrong let me try to show it 
with code assuming `while(warns not empty) sleep(1)`;
   
   - Test method starts and 'requireNetwork()' is called
   - Polling loop sees 0 warns so doesn't sleep
   - Test runs CQL and a warning is generated
   - Some 'requireNetwork' async call clears warnings
   - Assert fails as it sees 0 warnings instead of 1
   
   Now we do the same without polling
   
   - Test method starts and 'requireNetwork()' is called
   - Sleep(1) + some 'requireNetwork' async call clears warnings hopefully 
within the sleep. This is the source of flakiness
   - Test runs CQL and a warning is generated
   - Assert succeeds
   
   The problem is that waiting for warns to be empty is _not_ what we need. We 
need to wait for warns to be stable (aka requireNetwork to have finished 
completely). Now you can tell me I should do instead a `do sleep(1) 
while(!warns.empty())` and then it will work. But what's the point in polling 
on a random variable? It's like polling for pears when you're waiting on 
apples. It's the sleep that makes things work, the poll does nothing but 
confuse the reader imo.
   
   This is the best I can explain it. If I am not managing to explain it let's 
just remove or poll (any of both won't sleep) and then we can fix it when/if it 
starts failing in CI.




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

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