Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

[LW] Add logging to Timelock #5143

Merged
merged 6 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-5143.v2.yml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand All @@ -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<LockWatches> watches = new AtomicReference<>(LockWatches.create());
private final ReadWriteLock watchesLock = new ReentrantReadWriteLock(true);
Expand All @@ -73,7 +79,16 @@ public LockWatchingServiceImpl(HeldLocksCollection heldLocksCollection, Leadersh
@Override
public void startWatching(LockWatchRequest locksToWatch) {
Optional<LockWatches> 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<LockWatchReference> allReferences = watches.get().references();
log.info(
"All references currently watched",
SafeArg.of("sizeOfReferences", allReferences.size()),
UnsafeArg.of("allWatchedTables", allReferences));
}

@Override
Expand Down