This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cassandra-dtest.git


The following commit(s) were added to refs/heads/master by this push:
     new 9500cb9  Fix file size calculations racing with async file deletions
9500cb9 is described below

commit 9500cb982b579dba95e0765aa1c13b436777c3be
Author: Adam Holmberg <adam.holmb...@datastax.com>
AuthorDate: Tue Oct 13 09:28:47 2020 -0500

    Fix file size calculations racing with async file deletions
    
    Patch by Adam Holmberg, reviewed by brandonwilliams for CASSANDRA-16196
---
 disk_balance_test.py | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/disk_balance_test.py b/disk_balance_test.py
index 91ba848..1ff16a4 100644
--- a/disk_balance_test.py
+++ b/disk_balance_test.py
@@ -1,6 +1,7 @@
 import os
 import os.path
 import re
+from time import sleep
 
 import pytest
 import logging
@@ -165,13 +166,24 @@ class TestDiskBalance(Tester):
             self.assert_balanced(node)
 
     def assert_balanced(self, node):
-        sums = []
-        for sstabledir in node.get_sstables_per_data_directory('keyspace1', 
'standard1'):
-            sum = 0
-            for sstable in sstabledir:
-                sum = sum + os.path.getsize(sstable)
-            sums.append(sum)
-        assert_almost_equal(*sums, error=0.1, error_message=node.name)
+        old_sums = new_sums = None
+        # This extra looping and logic is to account for a race with obsolete 
file deletions, which are scheduled
+        # asynchronously in the server. We want to allow a chance to settle if 
files are still being removed
+        for _ in range(20):
+            old_sums = new_sums
+            new_sums = []
+            for sstabledir in 
node.get_sstables_per_data_directory('keyspace1', 'standard1'):
+                sum = 0
+                for sstable in sstabledir:
+                    sum = sum + os.path.getsize(sstable)
+                new_sums.append(sum)
+            if new_sums == old_sums:
+                break
+            sleep(2)
+
+        assert len(new_sums)
+        assert new_sums == old_sums  # we settled
+        assert_almost_equal(*new_sums, error=0.1, error_message=node.name)
 
     @since('3.10')
     def test_disk_balance_after_boundary_change_stcs(self):


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to