Skip to content
Permalink
Browse files

0003587: Noorder sequence for performance on Oracle RAC

  • Loading branch information...
erilong committed Jun 5, 2018
1 parent 5da3508 commit 25752f90bb4d6490fd9032b92d8eeb6468e33ad8
Showing with 29 additions and 8 deletions.
  1. +29 −8 symmetric-core/src/main/java/org/jumpmind/symmetric/route/DataGapRouteReader.java
@@ -88,6 +88,10 @@

protected boolean finishTransactionMode = false;

protected boolean isEachGapQueried;

protected boolean isOracleNoOrder;

protected String lastTransactionId = null;

protected static Map<String, Boolean> lastSelectUsedGreaterThanQueryByEngineName = new HashMap<String, Boolean>();
@@ -99,6 +103,7 @@ public DataGapRouteReader(ChannelRouterContext context, ISymmetricEngine engine)
this.percentOfHeapToUse = (double)parameterService.getInt(ParameterConstants.ROUTING_PEEK_AHEAD_MEMORY_THRESHOLD)/(double)100;
this.takeTimeout = engine.getParameterService().getInt(
ParameterConstants.ROUTING_WAIT_FOR_DATA_TIMEOUT_SECONDS, 330);
this.isOracleNoOrder = parameterService.is(ParameterConstants.DBDIALECT_ORACLE_SEQUENCE_NOORDER, false);
if (parameterService.is(ParameterConstants.SYNCHRONIZE_ALL_JOBS)) {
/* there will not be a separate thread to read a blocked queue so make sure the queue is big enough that it can be filled */
this.dataQueue = new LinkedBlockingQueue<Data>();
@@ -227,15 +232,28 @@ protected boolean process(Data data) {
if (!finishTransactionMode
|| (lastTransactionId != null && finishTransactionMode && lastTransactionId
.equals(data.getTransactionId()))) {
while (!okToProcess && currentGap != null && dataId >= currentGap.getStartId()) {
if (dataId <= currentGap.getEndId()) {
if (isOracleNoOrder) {
if (isEachGapQueried) {
okToProcess = true;
} else {
// past current gap. move to next gap
if (dataGaps.size() > 0) {
currentGap = dataGaps.remove(0);
for (DataGap gap : dataGaps) {
if (dataId >= gap.getStartId() && dataId <= gap.getEndId()) {
okToProcess = true;
break;
}
}
}
} else {
while (!okToProcess && currentGap != null && dataId >= currentGap.getStartId()) {
if (dataId <= currentGap.getEndId()) {
okToProcess = true;
} else {
currentGap = null;
// past current gap. move to next gap
if (dataGaps.size() > 0) {
currentGap = dataGaps.remove(0);
} else {
currentGap = null;
}
}
}
}
@@ -272,6 +290,7 @@ public Data take() throws InterruptedException {
useGreaterThanDataId = true;
}

isEachGapQueried = !useGreaterThanDataId && this.dataGaps.size() <= numberOfGapsToQualify;
String channelId = context.getChannel().getChannelId();

String sql = null;
@@ -297,7 +316,7 @@ public Data take() throws InterruptedException {
}
}

if (parameterService.is(ParameterConstants.DBDIALECT_ORACLE_SEQUENCE_NOORDER, false)) {
if (isOracleNoOrder) {
sql = String.format("%s %s", sql, engine.getRouterService().getSql("orderByCreateTime"));
} else if (parameterService.is(ParameterConstants.ROUTING_DATA_READER_ORDER_BY_DATA_ID_ENABLED, true)) {
sql = String.format("%s %s", sql, engine.getRouterService().getSql("orderByDataId"));
@@ -336,7 +355,9 @@ public Data take() throws InterruptedException {
}
}

this.currentGap = dataGaps.remove(0);
if (!isOracleNoOrder) {
this.currentGap = dataGaps.remove(0);
}

return sqlTemplate.queryForCursor(sql, new ISqlRowMapper<Data>() {
public Data mapRow(Row row) {

0 comments on commit 25752f9

Please sign in to comment.
You can’t perform that action at this time.