Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
title: Fix replication failure for files with exact MB sizes
type: fixed
authors:
- name: Shubham Ranjan
links:
- name: SOLR-18098
url: https://issues.apache.org/jira/browse/SOLR-18098
21 changes: 15 additions & 6 deletions solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -1752,26 +1752,35 @@ private int fetchPackets(FastInputStream fis) throws Exception {
aborted = true;
throw new ReplicationHandlerException("User aborted replication");
}
long checkSumServer = -1;

fis.readFully(intbytes);
// read the size of the packet
int packetSize = readInt(intbytes);

// EOF marker: size=0 with no trailing data (no checksum follows)
if (packetSize <= 0 && fis.peek() == -1) {
continue;
}

// read the checksum (all data packets have checksums, including zero-length ones)
long checkSumServer = -1;
if (checksum != null) {
fis.readFully(longbytes);
checkSumServer = readLong(longbytes);
}

// zero-length data packet: checksum already consumed, skip to next packet
if (packetSize <= 0) {
continue;
}

// TODO consider recoding the remaining logic to not use/need buf[]; instead use the
// internal buffer of fis
if (buf.length < packetSize) {
// This shouldn't happen since sender should use PACKET_SZ and we init the buf based on
// that too
buf = new byte[packetSize];
}
if (checksum != null) {
// read the checksum
fis.readFully(longbytes);
checkSumServer = readLong(longbytes);
}
// then read the packet of bytes
fis.readFully(buf, 0, packetSize);
// compare the checksum as sent from the leader
Expand Down
Loading