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

Commit

Permalink
[LW] Add logging to Timelock (#5143)
Browse files Browse the repository at this point in the history
* add further logging

* cut down logging

* Add generated changelog entries

* remove public

* eh
  • Loading branch information
Jolyon-S authored Dec 3, 2020
1 parent a1db6b5 commit 03a17cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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

0 comments on commit 03a17cf

Please sign in to comment.