internal/outcome/process: nil-safe unlock when failing to lock
All checks were successful
Test / Create distribution (push) Successful in 32s
Test / Hpkg (push) Successful in 4m13s
Test / Sandbox (push) Successful in 2m10s
Test / Hakurei (push) Successful in 3m9s
Test / Sandbox (race detector) (push) Successful in 4m7s
Test / Hakurei (race detector) (push) Successful in 4m57s
Test / Flake checks (push) Successful in 1m26s

This also prints a debug message which might be useful.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-11-02 11:47:51 +09:00
parent e7161f8e61
commit f5274067f6
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q

View File

@ -4,7 +4,6 @@ import (
"context"
"encoding/gob"
"errors"
"iter"
"math"
"os"
"os/exec"
@ -237,13 +236,15 @@ func (k *outcome) main(msg message.Msg) {
// this state transition to processFinal only
processState = processFinal
unlock, err := handle.Lock()
if err != nil {
unlock := func() { msg.Verbose("skipping unlock as lock was not successfully acquired") }
if f, err := handle.Lock(); err != nil {
perror(err, "acquire lock on store segment")
} else {
unlock = f
}
if entryHandle != nil {
if err = entryHandle.Destroy(); err != nil {
if err := entryHandle.Destroy(); err != nil {
perror(err, "destroy state entry")
}
}
@ -251,8 +252,7 @@ func (k *outcome) main(msg message.Msg) {
if isBeforeRevert {
ec := system.Process
var entries iter.Seq[*store.EntryHandle]
if entries, _, err = handle.Entries(); err != nil {
if entries, _, err := handle.Entries(); err != nil {
// it is impossible to continue from this point,
// per-process state will be reverted to limit damage
perror(err, "read store segment entries")
@ -287,7 +287,7 @@ func (k *outcome) main(msg message.Msg) {
}
}
if err = k.sys.Revert((*system.Criteria)(&ec)); err != nil {
if err := k.sys.Revert((*system.Criteria)(&ec)); err != nil {
var joinError interface {
Unwrap() []error
error