Skip to content

Commit

Permalink
0006057: fix conflict win marker from becoming a gap
Browse files Browse the repository at this point in the history
  • Loading branch information
erilong committed Nov 2, 2023
1 parent 51bb9c6 commit bfaccd0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,6 @@ public void commit() {
}
}

public void commitOnlyPrerouted() {
dataIds.addAll(uncommittedDataIds);
clearState();
}

public List<Long> getUncommittedDataIds() {
return uncommittedDataIds;
}

protected void clearState() {
this.usedDataRouters.clear();
this.timesByRouter.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ protected void saveContextLastId(MinMaxDeleteSql identifier, long lastId) {
* List of expired data gaps to avoid
* @return
*/
protected long[] getMinMaxAvoidGaps(long minId, long maxId, List<DataGap> dataGapsExpired) {
public static long[] getMinMaxAvoidGaps(long minId, long maxId, List<DataGap> dataGapsExpired) {
if (dataGapsExpired.size() > 0) {
Iterator<DataGap> iter = dataGapsExpired.iterator();
while (iter.hasNext()) {
Expand All @@ -730,8 +730,9 @@ protected long[] getMinMaxAvoidGaps(long minId, long maxId, List<DataGap> dataGa
// range is completely inside the gap
if (maxId <= gap.getEndId()) {
maxId = -(gap.getEndId() + 1);
break;
}
break;
iter.remove();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,6 @@ protected long routeDataForChannel(ProcessInfo processInfo, final NodeChannel no
// rolled back as exception, but let gap detector know about what was committed before halting
gapDetector.addDataIds(context.getDataIds());
gapDetector.setIsAllDataRead(false);
} else if (context.getUncommittedDataIds().size() > 0) {
context.commitOnlyPrerouted();
}
} catch (Exception e) {
if (context != null) {
Expand Down Expand Up @@ -765,6 +763,9 @@ protected long selectDataAndRoute(ProcessInfo processInfo, NodeCommunication nod
processInfo.incrementCurrentDataCount();
if (data.isPreRouted()) {
context.addData(data.getDataId());
statsDataCount++;
totalDataCount++;
totalDataEventCount++;
} else {
boolean atTransactionBoundary = false;
if (nextData != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.jumpmind.symmetric.service.impl;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import org.jumpmind.symmetric.model.DataGap;
import org.junit.jupiter.api.Test;

public class PurgeServiceTest {
@Test
public void testPurgeAroundSmallGaps() {
List<DataGap> gaps = new ArrayList<DataGap>();
gaps.add(new DataGap(1821, 1824));
gaps.add(new DataGap(1838, 1838));
long[] minMax = PurgeService.getMinMaxAvoidGaps(1821, 1846, gaps);
assertEquals(1825, minMax[0]);
assertEquals(1837, minMax[1]);
assertEquals(gaps.size(), 1);
minMax = PurgeService.getMinMaxAvoidGaps(1838, 1838, gaps);
assertEquals(-1839, minMax[1]);
assertEquals(gaps.size(), 1);
minMax = PurgeService.getMinMaxAvoidGaps(1838, 1846, gaps);
assertEquals(1839, minMax[0]);
assertEquals(1846, minMax[1]);
assertEquals(gaps.size(), 0);
}
}

0 comments on commit bfaccd0

Please sign in to comment.