10315: Update pending write size count just before packing small blocks to see if...
authorLucas Di Pentima <lucas@curoverse.com>
Fri, 28 Oct 2016 14:56:20 +0000 (11:56 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Fri, 28 Oct 2016 14:56:20 +0000 (11:56 -0300)
sdk/python/arvados/arvfile.py

index 2858a480ead0aa52454952ab4b1936d75817a3cf..7ee028db2a219e3d9a6f6c65314fb60273412002 100644 (file)
@@ -574,6 +574,13 @@ class _BlockManager(object):
                 # Not enough small blocks for repacking
                 return
 
+            # Update the pending write size count with its true value, just in case
+            # some small file was opened, written and closed several times.
+            if not force:
+                self._pending_write_size = sum([b.size() for b in small_blocks])
+                if self._pending_write_size < config.KEEP_BLOCK_SIZE:
+                    return
+
             new_bb = self._alloc_bufferblock()
             while len(small_blocks) > 0 and (new_bb.write_pointer + small_blocks[0].size()) <= config.KEEP_BLOCK_SIZE:
                 bb = small_blocks.pop(0)