3
0
mirror of https://github.com/Qortal/qortal.git synced 2025-02-12 10:15:49 +00:00

Merge branch 'Qortal:master' into master

This commit is contained in:
Marco Moesman 2021-07-01 10:24:03 +02:00 committed by GitHub
commit 39d8750ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 10 deletions

View File

@ -55,7 +55,7 @@ public class HSQLDBRepository implements Repository {
private static final Logger LOGGER = LogManager.getLogger(HSQLDBRepository.class);
private static final Object CHECKPOINT_LOCK = new Object();
public static final Object CHECKPOINT_LOCK = new Object();
// "serialization failure"
private static final Integer DEADLOCK_ERROR_CODE = Integer.valueOf(-4861);
@ -703,8 +703,11 @@ public class HSQLDBRepository implements Repository {
private ResultSet checkedExecuteResultSet(PreparedStatement preparedStatement, Object... objects) throws SQLException {
bindStatementParams(preparedStatement, objects);
if (!preparedStatement.execute())
throw new SQLException("Fetching from database produced no results");
// synchronize to block new executions if checkpointing in progress
synchronized (CHECKPOINT_LOCK) {
if (!preparedStatement.execute())
throw new SQLException("Fetching from database produced no results");
}
ResultSet resultSet = preparedStatement.getResultSet();
if (resultSet == null)

View File

@ -61,13 +61,15 @@ public class HSQLDBSaver {
public boolean execute(HSQLDBRepository repository) throws SQLException {
String sql = this.formatInsertWithPlaceholders();
try {
PreparedStatement preparedStatement = repository.prepareStatement(sql);
this.bindValues(preparedStatement);
synchronized (HSQLDBRepository.CHECKPOINT_LOCK) {
try {
PreparedStatement preparedStatement = repository.prepareStatement(sql);
this.bindValues(preparedStatement);
return preparedStatement.execute();
} catch (SQLException e) {
throw repository.examineException(e);
return preparedStatement.execute();
} catch (SQLException e) {
throw repository.examineException(e);
}
}
}