iamaleksey commented on code in PR #3180:
URL: https://github.com/apache/cassandra/pull/3180#discussion_r1530702307
##########
src/java/org/apache/cassandra/hints/HintsWriteExecutor.java:
##########
@@ -260,19 +261,30 @@ 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;
+ store.getHintsSizes().put(descriptor, session.position());
Review Comment:
No need to put this in a finally block I'd say.
--
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]