iamaleksey commented on code in PR #3180:
URL: https://github.com/apache/cassandra/pull/3180#discussion_r1530627278


##########
src/java/org/apache/cassandra/hints/HintsWriteExecutor.java:
##########
@@ -260,19 +261,33 @@ private void flushInternal(Iterator<ByteBuffer> iterator, 
HintsStore store)
         long maxHintsFileSize = DatabaseDescriptor.getMaxHintsFileSize();
 
         HintsWriter writer = store.getOrOpenWriter();
+        HintsDescriptor descriptor = writer.descriptor();
 
+        // If the creation of a new session throws, we have not written 
anything anyway,
+        // so we do not need to update hints sizes.
+        // If we throw during appending, we will track how many bytes were 
written in finally block
         try (HintsWriter.Session session = writer.newSession(writeBuffer))
         {
-            while (iterator.hasNext())
+            try
+            {
+                while (iterator.hasNext())
+                {
+                    session.append(iterator.next());
+                    if (session.position() >= maxHintsFileSize)
+                        break;
+                }
+            }
+            finally
             {
-                session.append(iterator.next());
-                if (session.position() >= maxHintsFileSize)
-                    break;
+                Map<String, Long> hintsSizes = store.getHintsSizes();
+                hintsSizes.compute(descriptor.hintsFileName, (d, currentSize) 
->

Review Comment:
   (This is a capturing lambda fyi)



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