Skip to content

Commit ef5011d

Browse files
authored
Fixup a flaky AuctionMark unit test failure (#282)
Handles primary key conflict races by marking the transaction as a `UserAbortException` for `NewComment`s.
1 parent 29ce61a commit ef5011d

File tree

1 file changed

+9
-0
lines changed
  • src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures

1 file changed

+9
-0
lines changed

src/main/java/com/oltpbenchmark/benchmarks/auctionmark/procedures/NewComment.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.oltpbenchmark.api.SQLStmt;
2323
import com.oltpbenchmark.benchmarks.auctionmark.AuctionMarkConstants;
2424
import com.oltpbenchmark.benchmarks.auctionmark.util.AuctionMarkUtil;
25+
import com.oltpbenchmark.util.SQLUtil;
2526

2627
import java.sql.*;
2728

@@ -94,6 +95,14 @@ public Object[] run(Connection conn, Timestamp[] benchmarkTimes,
9495
currentTime)) {
9596
preparedStatement.executeUpdate();
9697
}
98+
catch (SQLException ex) {
99+
if (SQLUtil.isDuplicateKeyException(ex)) {
100+
throw new UserAbortException("item comment id " + ic_id + " already exists for item " + item_id + " and seller " + seller_id);
101+
}
102+
else {
103+
throw ex;
104+
}
105+
}
97106

98107
try (PreparedStatement preparedStatement = this.getPreparedStatement(conn, updateItemComments, item_id, seller_id)) {
99108
preparedStatement.executeUpdate();

0 commit comments

Comments
 (0)