Introduce goose v20 lease columns with heartbeat loops so only expired leases are marked interrupted on restart; add PG tests for concurrent stage advance, active lease survival, and backup migration idempotency. Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
330 B
Go
21 lines
330 B
Go
package taskrun
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
defaultLeaseTTL = 30 * time.Second
|
|
defaultHeartbeatPeriod = 10 * time.Second
|
|
)
|
|
|
|
func newWorkerID() string {
|
|
host, err := os.Hostname()
|
|
if err != nil || host == "" {
|
|
host = "local"
|
|
}
|
|
return fmt.Sprintf("%s-%d-%d", host, os.Getpid(), time.Now().UnixNano())
|
|
}
|