diff --git a/changelog/@unreleased/pr-5143.v2.yml b/changelog/@unreleased/pr-5143.v2.yml new file mode 100644 index 00000000000..893f23abfa5 --- /dev/null +++ b/changelog/@unreleased/pr-5143.v2.yml @@ -0,0 +1,5 @@ +type: fix +fix: + description: Add further logging to Timelock to log the current watched references. + links: + - https://github.com/palantir/atlasdb/pull/5143 diff --git a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/LockWatchingServiceImpl.java b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/LockWatchingServiceImpl.java index 1d563cd37f7..e844327cfd1 100644 --- a/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/LockWatchingServiceImpl.java +++ b/timelock-impl/src/main/java/com/palantir/atlasdb/timelock/lock/watch/LockWatchingServiceImpl.java @@ -29,6 +29,8 @@ import com.palantir.lock.watch.LockWatchReferences.LockWatchReference; import com.palantir.lock.watch.LockWatchStateUpdate; import com.palantir.lock.watch.LockWatchVersion; +import com.palantir.logsafe.SafeArg; +import com.palantir.logsafe.UnsafeArg; import java.util.HashSet; import java.util.Optional; import java.util.Set; @@ -39,6 +41,8 @@ import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Note on concurrency: We use a fair read write lock mechanism and synchronisation as follows: @@ -57,6 +61,8 @@ */ @SuppressWarnings("UnstableApiUsage") public class LockWatchingServiceImpl implements LockWatchingService { + private static final Logger log = LoggerFactory.getLogger(LockWatchingServiceImpl.class); + private final LockEventLog lockEventLog; private final AtomicReference watches = new AtomicReference<>(LockWatches.create()); private final ReadWriteLock watchesLock = new ReentrantReadWriteLock(true); @@ -73,7 +79,16 @@ public LockWatchingServiceImpl(HeldLocksCollection heldLocksCollection, Leadersh @Override public void startWatching(LockWatchRequest locksToWatch) { Optional changes = addToWatches(locksToWatch); + changes.ifPresent(changedWatches -> log.info( + "New references watched", + SafeArg.of("sizeOfReferences", changedWatches.references().size()), + UnsafeArg.of("references", changedWatches.references()))); changes.ifPresent(this::logLockWatchEvent); + Set allReferences = watches.get().references(); + log.info( + "All references currently watched", + SafeArg.of("sizeOfReferences", allReferences.size()), + UnsafeArg.of("allWatchedTables", allReferences)); } @Override