Skip to content

Commit

Permalink
Added logging for stale events
Browse files Browse the repository at this point in the history
Signed-off-by: Oleg Mazurov <[email protected]>
  • Loading branch information
OlegMazurov committed Sep 5, 2024
1 parent 0868674 commit 4326e25
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.swirlds.platform.event.stale;

import static com.swirlds.logging.legacy.LogMarker.INVALID_EVENT_ERROR;
import static com.swirlds.platform.event.AncientMode.BIRTH_ROUND_THRESHOLD;

import com.swirlds.common.context.PlatformContext;
Expand All @@ -33,13 +34,17 @@
import java.util.List;
import java.util.Objects;
import java.util.function.ToLongFunction;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
* Detects when a self event becomes stale. Note that this detection may not observe a self event go stale if the node
* needs to reconnect or restart.
*/
public class DefaultStaleEventDetector implements StaleEventDetector {

private static final Logger logger = LogManager.getLogger(DefaultStaleEventDetector.class);

/**
* The ID of this node.
*/
Expand Down Expand Up @@ -102,6 +107,11 @@ public List<RoutableData<StaleEventDetectorOutput>> addSelfEvent(@NonNull final
if (currentEventWindow.isAncient(event)) {
// Although unlikely, it is plausible for an event to go stale before it is added to the detector.
handleStaleEvent(event);
logger.warn(INVALID_EVENT_ERROR.getMarker(), "addSelfEvent gen: {} created: {} #txn: {} threshold: {}",
event.getGeneration(),
event.getTimeCreated(),
event.getTransactionCount(),
currentEventWindow.getAncientThreshold());

final RoutableData<StaleEventDetectorOutput> staleEvent =
new RoutableData<>(StaleEventDetectorOutput.STALE_SELF_EVENT, event);
Expand Down Expand Up @@ -132,6 +142,11 @@ public List<RoutableData<StaleEventDetectorOutput>> addConsensusRound(
final List<RoutableData<StaleEventDetectorOutput>> output = new ArrayList<>(staleEvents.size());
for (final PlatformEvent event : staleEvents) {
handleStaleEvent(event);
logger.warn(INVALID_EVENT_ERROR.getMarker(), "addConsensusRound gen: {} created: {} #txn: {} threshold: {}",
event.getGeneration(),
event.getTimeCreated(),
event.getTransactionCount(),
currentEventWindow.getAncientThreshold());
output.add(new RoutableData<>(StaleEventDetectorOutput.STALE_SELF_EVENT, event));
}

Expand Down

0 comments on commit 4326e25

Please sign in to comment.