From eff522e4e38b11432f518d1b43fda01d8d387ca4 Mon Sep 17 00:00:00 2001 From: "Tschaen, Brendan" Date: Tue, 16 Apr 2019 09:51:58 -0400 Subject: Row re-use fix This prevents rows from being split properly, will follow up on issue Change-Id: I6d9ebbf8cf9abd2cac4992be407fb6cb44cb318b Issue-ID: MUSIC-326 Signed-off-by: Tschaen, Brendan --- .../main/java/org/onap/music/mdbc/DatabasePartition.java | 14 ++++++++++++++ .../main/java/org/onap/music/mdbc/mixins/MusicMixin.java | 3 ++- .../onap/music/mdbc/ownership/OwnershipAndCheckpoint.java | 14 +++++++------- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java index 4204960..c8cad47 100755 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java @@ -195,4 +195,18 @@ public class DatabasePartition { } return false; } + + /** + * Checks if the database partition contains all of the ranges + * @param ranges + * @return + */ + public synchronized boolean contains(List ranges) { + for (Range range: ranges) { + if (!isContained(range)) { + return false; + } + } + return true; + } } \ No newline at end of file diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java index e41b7c0..cb37a55 100644 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java @@ -2124,7 +2124,8 @@ public class MusicMixin implements MusicInterface { public OwnershipReturn mergeLatestRowsIfNecessary(Dag extendedDag, List latestRows, List ranges, Map locks, UUID ownershipId) throws MDBCServiceException { recoverFromFailureAndUpdateDag(extendedDag,latestRows,ranges,locks); - if (latestRows.size()==1) { + + if (latestRows.size()==1 && latestRows.get(0).getDBPartition().contains(ranges)) { //reuse current row if possible MusicRangeInformationRow row = latestRows.get(0); LockResult lockresult = locks.get(row.getPartitionIndex()); diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java index 8823b81..110cc80 100644 --- a/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java +++ b/mdbc-server/src/main/java/org/onap/music/mdbc/ownership/OwnershipAndCheckpoint.java @@ -293,8 +293,8 @@ public class OwnershipAndCheckpoint{ //Find Map newLocks = new HashMap<>(); List rangesToOwn = mi.getRangeDependencies(ranges); - List rows = extractRowsForRange(mi,rangesToOwn, false); - Dag toOwn = Dag.getDag(rows,rangesToOwn); + List rangesToOwnRows = extractRowsForRange(mi,rangesToOwn, false); + Dag toOwn = Dag.getDag(rangesToOwnRows,rangesToOwn); Dag currentlyOwn = new Dag(); while ( (toOwn.isDifferent(currentlyOwn) || !currentlyOwn.isOwned() ) && !timeout(opId) @@ -302,8 +302,8 @@ public class OwnershipAndCheckpoint{ takeOwnershipOfDag(mi, currPartition, opId, newLocks, toOwn); currentlyOwn=toOwn; //TODO instead of comparing dags, compare rows - rows = extractRowsForRange(mi, rangesToOwn, false); - toOwn = Dag.getDag(rows,rangesToOwn); + rangesToOwnRows = extractRowsForRange(mi, rangesToOwn, false); + toOwn = Dag.getDag(rangesToOwnRows,rangesToOwn); } if (!currentlyOwn.isOwned() || toOwn.isDifferent(currentlyOwn)) { //hold on to previous partition @@ -314,9 +314,9 @@ public class OwnershipAndCheckpoint{ throw new MDBCServiceException("Ownership timeout"); } Set allRanges = currentlyOwn.getAllRanges(); - List isLatestRows = extractRowsForRange(mi, new ArrayList<>(allRanges), true); - currentlyOwn.setRowsPerLatestRange(getIsLatestPerRange(toOwn,isLatestRows)); - return mi.mergeLatestRowsIfNecessary(currentlyOwn,rows,ranges,newLocks,opId); + List latestRows = extractRowsForRange(mi, new ArrayList<>(allRanges), true); + currentlyOwn.setRowsPerLatestRange(getIsLatestPerRange(toOwn,latestRows)); + return mi.mergeLatestRowsIfNecessary(currentlyOwn,latestRows,ranges,newLocks,opId); } /** -- cgit 1.2.3-korg