LOG.debug(String.format("No conflicts between %s<->%s",
dtxn, candidate));
return (false);
}
final ConflictSet dtxn_conflicts = dtxn_proc.getConflicts().get(ts_proc.getName());
final ConflictSet ts_conflicts = ts_proc.getConflicts().get(dtxn_proc.getName());
// If TS is going to write to something that DTXN will read or write, then
// we can let that slide as long as DTXN hasn't read from or written to those tables yet
if (dtxn_hasRWConflict || dtxn_hasWWConflict) {
assert(dtxn_conflicts != null) :
String.format("Unexpected null DTXN ConflictSet for %s -> %s",
dtxn_proc.getName(), ts_proc.getName());
// READ-WRITE
if (debug.val && dtxn_conflicts.getReadwriteconflicts().isEmpty() == false)
LOG.debug(String.format("Examining %d R-W Conflicts from %s -> %s",
dtxn_conflicts.getReadwriteconflicts().size(), dtxn_proc.getName(), ts_proc.getName()));
for (ConflictPair conflict : dtxn_conflicts.getReadwriteconflicts().values()) {
assert(conflict != null) :
String.format("Unexpected null DTXN R/W ConflictSet tables for %s [candidate=%s]",
dtxn_proc.getName(), ts_proc.getName());
for (TableRef ref : conflict.getTables().values()) {
assert(ref.getTable() != null) :
String.format("Unexpected null table reference %s [%s -> %s]",
ref.fullName(), dtxn_proc.getName(), ts_proc.getName());
if (dtxn.isTableReadOrWritten(partitionId, ref.getTable())) {
return (true);
}
} // FOR
} // FOR (R-W)
// WRITE-WRITE
if (debug.val && dtxn_conflicts.getWritewriteconflicts().isEmpty() == false)
LOG.debug(String.format("Examining %d W-W Conflicts from %s -> %s",
dtxn_conflicts.getWritewriteconflicts().size(), dtxn_proc.getName(), ts_proc.getName()));
for (ConflictPair conflict : dtxn_conflicts.getWritewriteconflicts().values()) {
assert(conflict != null) :
String.format("Unexpected null ConflictSet for %s [candidate=%s]",
dtxn_proc.getName(), ts_proc.getName());
for (TableRef ref : conflict.getTables().values()) {
assert(ref.getTable() != null) :
String.format("Unexpected null table reference %s [%s -> %s]",
ref.fullName(), dtxn_proc.getName(), ts_proc.getName());
if (dtxn.isTableReadOrWritten(partitionId, ref.getTable())) {
return (true);
}
}
} // FOR (W-W)
}
// Similarly, if the TS needs to read from (but not write to) a table that DTXN
// writes to, then we can allow TS to execute if DTXN hasn't written anything to
// those tables yet
if (ts_hasRWConflict && ts_hasWWConflict == false) {
assert(ts_conflicts != null) :
String.format("Unexpected null ConflictSet for %s -> %s",
ts_proc.getName(), dtxn_proc.getName());
if (debug.val) LOG.debug(String.format("%s has R-W conflict with %s. Checking read/write sets", candidate, dtxn));
for (ConflictPair conflict : ts_conflicts.getReadwriteconflicts().values()) {
assert(conflict != null) :
String.format("Unexpected null ConflictSet for %s [candidate=%s]",
dtxn_proc.getName(), ts_proc.getName());
for (TableRef ref : conflict.getTables().values()) {
assert(ref.getTable() != null) :