Skip to content

Commit

Permalink
Fix concurrent modification error in AuctionMark (cmu-db#357)
Browse files Browse the repository at this point in the history
Co-authored-by: Andy Pavlo <[email protected]>
  • Loading branch information
nuno-faria and apavlo authored Sep 26, 2023
1 parent 0119278 commit 109064e
Showing 1 changed file with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ public void updateItemQueues() {
continue;
}

for (ItemInfo itemInfo : items) {
this.addItemToProperQueue(itemInfo, currentTime);
for (Iterator<ItemInfo> it = items.iterator(); it.hasNext();) {
this.addItemToProperQueue(it.next(), currentTime, it);
}
}

Expand All @@ -767,10 +767,10 @@ public ItemStatus addItemToProperQueue(ItemInfo itemInfo, boolean is_loader) {
Timestamp baseTime = (is_loader ? this.getLoaderStartTime() : this.getCurrentTime());


return addItemToProperQueue(itemInfo, baseTime);
return addItemToProperQueue(itemInfo, baseTime, null);
}

private ItemStatus addItemToProperQueue(ItemInfo itemInfo, Timestamp baseTime) {
private ItemStatus addItemToProperQueue(ItemInfo itemInfo, Timestamp baseTime, Iterator<ItemInfo> currentQueueIterator) {
// Always check whether we even want it for this client
// The loader's profile and the cache profile will always have a negative client_id,
// which means that we always want to keep it
Expand Down Expand Up @@ -799,30 +799,25 @@ private ItemStatus addItemToProperQueue(ItemInfo itemInfo, Timestamp baseTime) {


if (!new_status.equals(existingStatus)) {
// Remove the item from the current queue
if (currentQueueIterator != null) {
currentQueueIterator.remove();
}

switch (new_status) {
case OPEN:
this.addItem(this.items_available, itemInfo);
break;
case ENDING_SOON:
this.items_available.remove(itemInfo);
this.addItem(this.items_endingSoon, itemInfo);
break;
case WAITING_FOR_PURCHASE:
(existingStatus == ItemStatus.OPEN ? this.items_available : this.items_endingSoon).remove(itemInfo);
this.addItem(this.items_waitingForPurchase, itemInfo);
break;
case CLOSED:
if (existingStatus == ItemStatus.OPEN) {
this.items_available.remove(itemInfo);
} else if (existingStatus == ItemStatus.ENDING_SOON) {
this.items_endingSoon.remove(itemInfo);
} else {
this.items_waitingForPurchase.remove(itemInfo);
}
this.addItem(this.items_completed, itemInfo);
break;
default:

}
itemInfo.setStatus(new_status);
}
Expand Down

0 comments on commit 109064e

Please sign in to comment.