Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrent modification error in AuctionMark #357

Merged
merged 3 commits into from
Sep 26, 2023

Conversation

nuno-faria
Copy link
Contributor

In the updateItemQueues function, the code iterates each item queue and calls the addItemToProperQueue for each item. One step this function does is remove the item from the original list, if the new status is different from the old one.
This, however, triggers a ConcurrentModificationException exception since we are iterating and removing concurrently from the linked list:

java.util.ConcurrentModificationException
	at java.base/java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:970)
	at java.base/java.util.LinkedList$ListItr.next(LinkedList.java:892)
	at com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkProfile.updateItemQueues(AuctionMarkProfile.java:749)
	at com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkWorker.executeCloseAuctions(AuctionMarkWorker.java:454)
	at com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkWorker.executeWork(AuctionMarkWorker.java:350)
	at com.oltpbenchmark.api.Worker.doWork(Worker.java:416)
	at com.oltpbenchmark.api.Worker.run(Worker.java:282)
	at java.base/java.lang.Thread.run(Thread.java:833)

The proposed solution passes a reference to the iterator in the updateItemQueues function, so the addItemToProperQueue can safely remove the element using iterator.remove(). This also means that the code in the addItemToProperQueue function does not need to iterate over the entire list again by calling remove, improving performance. The other functions that call updateItemQueues seem to be always new items, so we can set the iterator as null as they don't need to remove from an existing queue.

@apavlo apavlo added the bug Something isn't working label Sep 19, 2023
Copy link
Member

@apavlo apavlo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@apavlo apavlo added the ready-to-merge This PR is ready to be merged. label Sep 19, 2023
@apavlo apavlo merged commit 109064e into cmu-db:main Sep 26, 2023
100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-to-merge This PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants