Skip to content

Commit 109064e

Browse files
nuno-fariaapavlo
andauthored
Fix concurrent modification error in AuctionMark (#357)
Co-authored-by: Andy Pavlo <[email protected]>
1 parent 0119278 commit 109064e

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/main/java/com/oltpbenchmark/benchmarks/auctionmark/AuctionMarkProfile.java

+9-14
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ public void updateItemQueues() {
746746
continue;
747747
}
748748

749-
for (ItemInfo itemInfo : items) {
750-
this.addItemToProperQueue(itemInfo, currentTime);
749+
for (Iterator<ItemInfo> it = items.iterator(); it.hasNext();) {
750+
this.addItemToProperQueue(it.next(), currentTime, it);
751751
}
752752
}
753753

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

769769

770-
return addItemToProperQueue(itemInfo, baseTime);
770+
return addItemToProperQueue(itemInfo, baseTime, null);
771771
}
772772

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

800800

801801
if (!new_status.equals(existingStatus)) {
802+
// Remove the item from the current queue
803+
if (currentQueueIterator != null) {
804+
currentQueueIterator.remove();
805+
}
806+
802807
switch (new_status) {
803808
case OPEN:
804809
this.addItem(this.items_available, itemInfo);
805810
break;
806811
case ENDING_SOON:
807-
this.items_available.remove(itemInfo);
808812
this.addItem(this.items_endingSoon, itemInfo);
809813
break;
810814
case WAITING_FOR_PURCHASE:
811-
(existingStatus == ItemStatus.OPEN ? this.items_available : this.items_endingSoon).remove(itemInfo);
812815
this.addItem(this.items_waitingForPurchase, itemInfo);
813816
break;
814817
case CLOSED:
815-
if (existingStatus == ItemStatus.OPEN) {
816-
this.items_available.remove(itemInfo);
817-
} else if (existingStatus == ItemStatus.ENDING_SOON) {
818-
this.items_endingSoon.remove(itemInfo);
819-
} else {
820-
this.items_waitingForPurchase.remove(itemInfo);
821-
}
822818
this.addItem(this.items_completed, itemInfo);
823819
break;
824820
default:
825-
826821
}
827822
itemInfo.setStatus(new_status);
828823
}

0 commit comments

Comments
 (0)