Skip to content

Commit

Permalink
Improve throughput in case of oracle database
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasrutishauser committed Jul 28, 2024
1 parent 4f99a65 commit 9b75af2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public synchronized void schedule() {
} catch (RejectedExecutionException e) {
LOGGER.warn("Failed to dispatch events: {}", e.getMessage());
}
if (processed || maxAquire <= 0) {
if (processed || maxAquire <= configuration.getMaxConcurrentDispatching() / 10) {
intervalSeconds = 0;
} else {
intervalSeconds = min(configuration.getMaxDispatchInterval(), max(intervalSeconds * 2, 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public Set<String> aquire(int maxAquire) {
PreparedStatement aquireStatement = connection.prepareStatement(aquireSQL);
ResultSet resultSet = executeQuery(aquireStatement, lockOwner.getMinUntilForAquire(), limit);
PreparedStatement updateStatement = connection.prepareStatement(updateSQL)) {
while (resultSet.next()) {
while (limit-- > 0 && resultSet.next()) {
result.add(resultSet.getString("id"));
updateStatement.setInt(1, resultSet.getInt("tries"));
updateStatement.setString(2, lockOwner.getId());
Expand Down Expand Up @@ -305,7 +305,11 @@ private ResultSet executeQuery(PreparedStatement statement, int intParam) throws

private ResultSet executeQuery(PreparedStatement statement, long param1, int param2) throws SQLException {
statement.setLong(1, param1);
statement.setInt(2, param2);
if (statement.getParameterMetaData().getParameterCount() > 1) {
statement.setInt(2, param2);
} else {
statement.setFetchSize(1);
}
return statement.executeQuery();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public String addSkipLocked(String sql) {
private static class SkipLockedQueryAdapter extends SimpleQueryAdapter {
@Override
public String addSkipLocked(String sql) {
return sql.replace("FOR UPDATE", "FOR UPDATE SKIP LOCKED");
return sql.replaceAll(LIMIT_EXPRESSION, "").replace("FOR UPDATE", "FOR UPDATE SKIP LOCKED");
}
}

Expand Down

0 comments on commit 9b75af2

Please sign in to comment.