sashapolo commented on code in PR #6753:
URL: https://github.com/apache/ignite-3/pull/6753#discussion_r2439914282


##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/storage/segstore/SegmentFileManager.java:
##########
@@ -165,32 +170,23 @@ private static SegmentFileWithMemtable 
convertToReadOnly(SegmentFileWithMemtable
     void appendEntry(long groupId, LogEntry entry, LogEntryEncoder encoder) 
throws IOException {
         int entrySize = encoder.size(entry);
 
-        if (entrySize > maxEntrySize()) {
+        if (entrySize > maxPossibleEntrySize()) {
             throw new IllegalArgumentException(String.format(
-                    "Entry size is too big (%d bytes), maximum allowed entry 
size: %d bytes.", entrySize, maxEntrySize()
+                    "Entry size is too big (%d bytes), maximum allowed entry 
size: %d bytes.", entrySize, maxPossibleEntrySize()
             ));
         }
 
         int payloadSize = SegmentPayload.size(entrySize);
 
-        while (true) {
-            SegmentFileWithMemtable segmentFileWithMemtable = 
currentSegmentFile();
-
-            try (WriteBuffer writeBuffer = 
segmentFileWithMemtable.segmentFile().reserve(payloadSize)) {
-                if (writeBuffer != null) {
-                    int segmentOffset = writeBuffer.buffer().position();
+        try (WriteBufferWithMemtable writeBufferWithMemtable = 
reserveBytesWithRollover(payloadSize)) {
+            ByteBuffer segmentBuffer = writeBufferWithMemtable.buffer();
 
-                    SegmentPayload.writeTo(writeBuffer.buffer(), groupId, 
entrySize, entry, encoder);
+            int segmentOffset = segmentBuffer.position();
 
-                    // Append to memtable before write buffer is released to 
avoid races with checkpoint on rollover.
-                    
segmentFileWithMemtable.memtable().appendSegmentFileOffset(groupId, 
entry.getId().getIndex(), segmentOffset);
-
-                    return;
-                }
-            }
+            SegmentPayload.writeTo(segmentBuffer, groupId, entrySize, entry, 
encoder);
 
-            // Segment file does not have enough space. Try to switch to a new 
one and retry the write attempt.
-            initiateRollover(segmentFileWithMemtable);
+            // Append to memtable before write buffer is released to avoid 
races with checkpoint on rollover.
+            writeBufferWithMemtable.memtable.appendSegmentFileOffset(groupId, 
entry.getId().getIndex(), segmentOffset);

Review Comment:
   We currently wait for all writes during the checkpoint before flush. I 
expect to implement a more granular flush in 
https://issues.apache.org/jira/browse/IGNITE-26292



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

Reply via email to