|
41 | 41 | import java.nio.file.StandardOpenOption;
|
42 | 42 | import java.util.HashMap;
|
43 | 43 | import java.util.Map;
|
| 44 | +import java.util.Objects; |
44 | 45 | import java.util.concurrent.atomic.AtomicBoolean;
|
45 | 46 | import java.util.function.LongSupplier;
|
46 | 47 |
|
@@ -202,9 +203,27 @@ private synchronized boolean assertNoSeqNumberConflict(long seqNo, BytesReferenc
|
202 | 203 | if (previous.v1().equals(data) == false) {
|
203 | 204 | Translog.Operation newOp = Translog.readOperation(new BufferedChecksumStreamInput(data.streamInput()));
|
204 | 205 | Translog.Operation prvOp = Translog.readOperation(new BufferedChecksumStreamInput(previous.v1().streamInput()));
|
205 |
| - throw new AssertionError( |
206 |
| - "seqNo [" + seqNo + "] was processed twice in generation [" + generation + "], with different data. " + |
207 |
| - "prvOp [" + prvOp + "], newOp [" + newOp + "]", previous.v2()); |
| 206 | + // we need to exclude versionType from this check because it's removed in 7.0 |
| 207 | + final boolean sameOp; |
| 208 | + if (prvOp instanceof Translog.Index && newOp instanceof Translog.Index) { |
| 209 | + final Translog.Index o1 = (Translog.Index) prvOp; |
| 210 | + final Translog.Index o2 = (Translog.Index) newOp; |
| 211 | + sameOp = Objects.equals(o1.id(), o2.id()) && Objects.equals(o1.type(), o2.type()) |
| 212 | + && Objects.equals(o1.source(), o2.source()) && Objects.equals(o1.routing(), o2.routing()) |
| 213 | + && o1.primaryTerm() == o2.primaryTerm() && o1.seqNo() == o2.seqNo() && o1.version() == o2.version(); |
| 214 | + } else if (prvOp instanceof Translog.Delete && newOp instanceof Translog.Delete) { |
| 215 | + final Translog.Delete o1 = (Translog.Delete) prvOp; |
| 216 | + final Translog.Delete o2 = (Translog.Delete) newOp; |
| 217 | + sameOp = Objects.equals(o1.id(), o2.id()) && Objects.equals(o1.type(), o2.type()) |
| 218 | + && o1.primaryTerm() == o2.primaryTerm() && o1.seqNo() == o2.seqNo() && o1.version() == o2.version(); |
| 219 | + } else { |
| 220 | + sameOp = false; |
| 221 | + } |
| 222 | + if (sameOp == false) { |
| 223 | + throw new AssertionError( |
| 224 | + "seqNo [" + seqNo + "] was processed twice in generation [" + generation + "], with different data. " + |
| 225 | + "prvOp [" + prvOp + "], newOp [" + newOp + "]", previous.v2()); |
| 226 | + } |
208 | 227 | }
|
209 | 228 | } else {
|
210 | 229 | seenSequenceNumbers.put(seqNo,
|
|
0 commit comments