mirror of
https://github.com/Qortal/qortal.git
synced 2025-08-01 14:41:23 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f19e0498bf | ||
|
32ec02225a | ||
|
3920933fc7 | ||
|
1fdd7f156c |
2
pom.xml
2
pom.xml
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.qortal</groupId>
|
||||
<artifactId>qortal</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>1.4.2</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<skipTests>true</skipTests>
|
||||
|
@@ -806,7 +806,10 @@ public class Controller extends Thread {
|
||||
|
||||
repository.saveChanges();
|
||||
} catch (DataException e) {
|
||||
LOGGER.error("Repository issue while deleting expired unconfirmed transactions", e);
|
||||
if (RepositoryManager.isDeadlockRelated(e))
|
||||
LOGGER.info("Couldn't delete some expired, unconfirmed transactions this round");
|
||||
else
|
||||
LOGGER.error("Repository issue while deleting expired unconfirmed transactions", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -488,7 +488,9 @@ public class Synchronizer {
|
||||
peerBlockSignatures.remove(0);
|
||||
++ourHeight;
|
||||
|
||||
LOGGER.trace(String.format("Fetching block %d, sig %.8s from %s", ourHeight, Base58.encode(latestPeerSignature), peer));
|
||||
Block newBlock = this.fetchBlock(repository, peer, latestPeerSignature);
|
||||
LOGGER.trace(String.format("Fetched block %d, sig %.8s from %s", ourHeight, Base58.encode(latestPeerSignature), peer));
|
||||
|
||||
if (newBlock == null) {
|
||||
LOGGER.info(String.format("Peer %s failed to respond with block for height %d, sig %.8s", peer,
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package org.qortal.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public interface RepositoryFactory {
|
||||
|
||||
public boolean wasPristineAtOpen();
|
||||
@@ -12,4 +14,7 @@ public interface RepositoryFactory {
|
||||
|
||||
public void close() throws DataException;
|
||||
|
||||
// Not ideal place for this but implementating class will know the answer without having to open a new DB session
|
||||
public boolean isDeadlockException(SQLException e);
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package org.qortal.repository;
|
||||
|
||||
import java.sql.SQLException;
|
||||
|
||||
public abstract class RepositoryManager {
|
||||
|
||||
private static RepositoryFactory repositoryFactory = null;
|
||||
@@ -69,4 +71,10 @@ public abstract class RepositoryManager {
|
||||
repositoryFactory = oldRepositoryFactory.reopen();
|
||||
}
|
||||
|
||||
public static boolean isDeadlockRelated(Throwable e) {
|
||||
Throwable cause = e.getCause();
|
||||
|
||||
return SQLException.class.isInstance(cause) && repositoryFactory.isDeadlockException((SQLException) cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -59,6 +59,9 @@ public class HSQLDBRepository implements Repository {
|
||||
|
||||
private static final Object CHECKPOINT_LOCK = new Object();
|
||||
|
||||
// "serialization failure"
|
||||
private static final Integer DEADLOCK_ERROR_CODE = Integer.valueOf(-4861);
|
||||
|
||||
protected Connection connection;
|
||||
protected final Deque<Savepoint> savepoints = new ArrayDeque<>(3);
|
||||
protected boolean debugState = false;
|
||||
@@ -708,7 +711,16 @@ public class HSQLDBRepository implements Repository {
|
||||
|
||||
long beforeQuery = this.slowQueryThreshold == null ? 0 : System.currentTimeMillis();
|
||||
|
||||
int[] updateCounts = preparedStatement.executeBatch();
|
||||
int[] updateCounts = null;
|
||||
try {
|
||||
updateCounts = preparedStatement.executeBatch();
|
||||
} catch (SQLException e) {
|
||||
if (isDeadlockException(e))
|
||||
// We want more info on what other DB sessions are doing to cause this
|
||||
examineException(e);
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (this.slowQueryThreshold != null) {
|
||||
long queryTime = System.currentTimeMillis() - beforeQuery;
|
||||
@@ -1000,4 +1012,8 @@ public class HSQLDBRepository implements Repository {
|
||||
return Crypto.toAddress(publicKey);
|
||||
}
|
||||
|
||||
/*package*/ static boolean isDeadlockException(SQLException e) {
|
||||
return DEADLOCK_ERROR_CODE.equals(e.getErrorCode());
|
||||
}
|
||||
|
||||
}
|
@@ -148,4 +148,9 @@ public class HSQLDBRepositoryFactory implements RepositoryFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDeadlockException(SQLException e) {
|
||||
return HSQLDBRepository.isDeadlockException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
10
stop.sh
10
stop.sh
@@ -21,13 +21,19 @@ fi
|
||||
read pid 2>/dev/null <run.pid
|
||||
is_pid_valid=$?
|
||||
|
||||
# Swap out the API port if the --testnet (or -t) argument is specified
|
||||
api_port=12391
|
||||
if [[ "$@" = *"--testnet"* ]] || [[ "$@" = *"-t"* ]]; then
|
||||
api_port=62391
|
||||
fi
|
||||
|
||||
# Ensure curl is installed
|
||||
curl_path=$(which curl)
|
||||
|
||||
if [[ -f $curl_path ]]; then
|
||||
|
||||
echo 'Calling GET /admin/stop on local Qortal node'
|
||||
if curl --url http://localhost:12391/admin/stop 1>/dev/null 2>&1; then
|
||||
if curl --url "http://localhost:${api_port}/admin/stop" 1>/dev/null 2>&1; then
|
||||
echo "Qortal node responded and should be shutting down"
|
||||
|
||||
if [ "${is_pid_valid}" -eq 0 ]; then
|
||||
@@ -42,7 +48,7 @@ if [[ -f $curl_path ]]; then
|
||||
fi
|
||||
exit 0
|
||||
else
|
||||
echo "${red}No response from Qortal node - not running?${normal}"
|
||||
echo "${red}No response from Qortal node - not running on port ${api_port}?${normal}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
Reference in New Issue
Block a user