During rewinding, only send "invalidated" progress notification if node was actually marked dirty: if a node is marked dirty concurrently by multiple parents, only one will actually mark it dirty.

PiperOrigin-RevId: 292936847
diff --git a/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java b/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java
index 1b4572a..574d806 100644
--- a/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java
+++ b/src/main/java/com/google/devtools/build/skyframe/AbstractParallelEvaluator.java
@@ -840,10 +840,11 @@
 
       // Nodes are marked "force-rebuild" to ensure that they run, and to allow them to evaluate to
       // a different value than before, even if their versions remain the same.
-      restartEntry.markDirty(DirtyType.FORCE_REBUILD);
-      evaluatorContext
-          .getProgressReceiver()
-          .invalidated(keyToRestart, EvaluationProgressReceiver.InvalidationState.DIRTY);
+      if (restartEntry.markDirty(DirtyType.FORCE_REBUILD) != null) {
+        evaluatorContext
+            .getProgressReceiver()
+            .invalidated(keyToRestart, EvaluationProgressReceiver.InvalidationState.DIRTY);
+      }
     }
 
     if (missingNodes != null) {
diff --git a/src/main/java/com/google/devtools/build/skyframe/EvaluationProgressReceiver.java b/src/main/java/com/google/devtools/build/skyframe/EvaluationProgressReceiver.java
index 09aa231..318dd6a 100644
--- a/src/main/java/com/google/devtools/build/skyframe/EvaluationProgressReceiver.java
+++ b/src/main/java/com/google/devtools/build/skyframe/EvaluationProgressReceiver.java
@@ -79,7 +79,10 @@
    *
    * <p>{@code state} indicates the new state of the value.
    *
-   * <p>May be called concurrently from multiple threads, possibly with the same {@code key}.
+   * <p>May be called concurrently from multiple threads.
+   *
+   * <p>If {@code state} is {@link InvalidationState#DIRTY}, should only be called after a
+   * successful {@link ThinNodeEntry#markDirty} call: a call that returns a non-null value.
    */
   void invalidated(SkyKey skyKey, InvalidationState state);