Skip to content

Commit

Permalink
Add the high-contention warning
Browse files Browse the repository at this point in the history
If the number of serialization-related retry is greater than predefined
value (currently 8) a warning is issued instead of the usual debug
message. This is to tell administrator that something wrong - i.e. high
contention - is occurring.

(backported from commit cf323c7)
  • Loading branch information
mederly committed Jul 4, 2018
1 parent 2495c13 commit 22fcf12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Expand Up @@ -99,6 +99,7 @@
public class SqlRepositoryServiceImpl extends SqlBaseService implements RepositoryService {

public static final String PERFORMANCE_LOG_NAME = SqlRepositoryServiceImpl.class.getName() + ".performance";
public static final int MAIN_LOG_WARN_THRESHOLD = 8;

private static final Trace LOGGER = TraceManager.getTrace(SqlRepositoryServiceImpl.class);
private static final Trace LOGGER_PERFORMANCE = TraceManager.getTrace(PERFORMANCE_LOG_NAME);
Expand Down
Expand Up @@ -209,9 +209,13 @@ public int logOperationAttempt(String oid, String operation, int attempt, Runtim
LOGGER.trace("Waiting: attempt = " + attempt + ", waitTimeInterval = 0.." + waitTimeInterval + ", waitTime = " + waitTime);
}

if (LOGGER.isDebugEnabled()) {
if (attempt >= SqlRepositoryServiceImpl.MAIN_LOG_WARN_THRESHOLD) {
LOGGER.warn("A serialization-related problem occurred when {} object with oid '{}', retrying after "
+ "{} ms (this was attempt {} of {})\n{}: {}", operation, oid, waitTime,
attempt, LOCKING_MAX_ATTEMPTS, ex.getClass().getSimpleName(), ex.getMessage());
} else {
LOGGER.debug("A serialization-related problem occurred when {} object with oid '{}', retrying after "
+ "{} ms (this was attempt {} of {})\n{}: {}", operation, oid, waitTime,
+ "{} ms (this was attempt {} of {})\n{}: {}", operation, oid, waitTime,
attempt, LOCKING_MAX_ATTEMPTS, ex.getClass().getSimpleName(), ex.getMessage());
}

Expand Down

0 comments on commit 22fcf12

Please sign in to comment.