Apply at most one idempotent write and turn the accepted and skipped counts into a commit, skip, or retry remediation action.

idempotent write Only the first write is accepted and later writes are counted as skipped, so the remediation action is reproducible without a live lazy initializer.

Lazy Value Remediation Report

writes
LazyValueRemediationReport.scala
Replay: real traced execution (multi-file project)
object Main {
  def main(args: Array[String]): Unit = {
    val writes = 1
    var accepted = 0
    var skipped = 0
    for (i <- 1 to writes) {
      if (accepted == 0) {
        accepted = accepted + 1
      } else {
        skipped = skipped + 1
      }
    }

    var action = "retry"
    if (accepted >= 1) {
      action = "commit"
    }
    if (skipped >= 1) {
      action = "skip"
    }

    println("writes=" + writes + " accepted=" + accepted + " skipped=" + skipped + " " + action)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val writes = 0
    var accepted = 0
    var skipped = 0
    for (i <- 1 to writes) {
      if (accepted == 0) {
        accepted = accepted + 1
      } else {
        skipped = skipped + 1
      }
    }

    var action = "retry"
    if (accepted >= 1) {
      action = "commit"
    }
    if (skipped >= 1) {
      action = "skip"
    }

    println("writes=" + writes + " accepted=" + accepted + " skipped=" + skipped + " " + action)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val writes = 2
    var accepted = 0
    var skipped = 0
    for (i <- 1 to writes) {
      if (accepted == 0) {
        accepted = accepted + 1
      } else {
        skipped = skipped + 1
      }
    }

    var action = "retry"
    if (accepted >= 1) {
      action = "commit"
    }
    if (skipped >= 1) {
      action = "skip"
    }

    println("writes=" + writes + " accepted=" + accepted + " skipped=" + skipped + " " + action)
  }
}
  1. writes ← 1, accepted ← 0, skipped ← 0

    1object Main {2  def main(args: Array[String]): Unit = {3    val writes→ 1 = 1 //@writes=2, 04    var accepted→ 0 = 05    var skipped→ 0 = 06    for (i <- 1 to writes) {7      if (accepted == 0) {
  2. for (i <- 1 to writes)

    5var skipped = 06for (i1 <- 1 to writes1) {7  if (accepted == 0) {
  3. accepted ← 1

    6for (i <- 1 to writes) {7  if (accepted0 == 0) {8    accepted→ 1 = accepted + 19  } else {10    skipped = skipped + 1
  4. action ← retry

    14var action→ retry = "retry"15if (accepted >= 1) {16  action = "commit"
  5. action ← commit

    14var action = "retry"15if (accepted1 >= 1) {16  action→ commit = "commit"17}18if (skipped >= 1) {
  6. println("writes=" + writes + " accepted=" + accepted + " skipped=" + s…

    22    println("writes=" + writes1 + " accepted=" + accepted1 + " skipped=" + skipped0 + " " + actioncommit)23  }24}
    outputwrites=1 accepted=1 skipped=0 commit
  1. writes ← 0, accepted ← 0, skipped ← 0, action ← retry

    1object Main {2  def main(args: Array[String]): Unit = {3    val writes→ 0 = 04    var accepted→ 0 = 05    var skipped→ 0 = 06    for (i <- 1 to writes) {7      if (accepted == 0) {8        accepted = accepted + 19      } else {10        skipped = skipped + 111      }12    }1314    var action→ retry = "retry"15    if (accepted >= 1) {16      action = "commit"17    }18    if (skipped >= 1) {19      action = "skip"20    }2122    println("writes=" + writes0 + " accepted=" + accepted0 + " skipped=" + skipped0 + " " + actionretry)23  }24}
    outputwrites=0 accepted=0 skipped=0 retry
  1. writes ← 2, accepted ← 0, skipped ← 0

    1object Main {2  def main(args: Array[String]): Unit = {3    val writes→ 2 = 24    var accepted→ 0 = 05    var skipped→ 0 = 06    for (i <- 1 to writes) {7      if (accepted == 0) {
  2. for (i <- 1 to writes)

    pass 1 of 2
    5var skipped = 06for (i1 <- 1 to writes2) {7  if (accepted == 0) {
  3. accepted ← 1

    6for (i <- 1 to writes) {7  if (accepted0 == 0) {8    accepted→ 1 = accepted + 19  } else {10    skipped = skipped + 1
  4. for (i <- 1 to writes)

    pass 2 of 2
    5var skipped = 06for (i2 <- 1 to writes2) {7  if (accepted == 0) {
  5. skipped ← 1

    8    accepted = accepted + 19  } else {10    skipped→ 1 = skipped + 111  }12}
  6. action ← retry

    14var action→ retry = "retry"15if (accepted >= 1) {16  action = "commit"
  7. action ← commit

    14var action = "retry"15if (accepted1 >= 1) {16  action→ commit = "commit"17}18if (skipped >= 1) {
  8. action ← skip

    17}18if (skipped1 >= 1) {19  action→ skip = "skip"20}
  9. println("writes=" + writes + " accepted=" + accepted + " skipped=" + s…

    22    println("writes=" + writes2 + " accepted=" + accepted1 + " skipped=" + skipped1 + " " + actionskip)23  }24}
    outputwrites=2 accepted=1 skipped=1 skip