Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions cmd/partforge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ The destination table must be empty by default. Set -require-empty=false only wh
Summary: "Move failed or stale parts back to the state where they can be retried.",
Details: `Failed rewrite parts go back to READY. Failed import parts go back to FINISHED so import-finished retries only the attach step.

Select exactly one of -all, -part-id, or -stale. -include-in-progress resets stuck IN_PROGRESS rows; -force retries selected rows regardless of current state.`,
Select exactly one of -all, -part-id, or -stale. -include-in-progress resets stuck IN_PROGRESS rows. To re-run a part that has not failed, use set-part-state; to re-run a whole job, use reset-job.`,
},
{
Name: "set-part-state",
Expand Down Expand Up @@ -3716,7 +3716,6 @@ func runRetryFailed(ctx context.Context, args []string) error {
stale = fs.Bool("stale", false, "retry IN_PROGRESS parts with stale persisted progress")
staleAfter = fs.Duration("stale-after", defaultRetryStaleAfter, "minimum age of progress_updated_at for -stale")
includeInProgress = fs.Bool("include-in-progress", false, "with -all or -part-id, also return selected IN_PROGRESS parts to READY")
force = fs.Bool("force", false, "retry selected parts regardless of current state")
stateTable = fs.String("state-table", defaultStateTable, "Postgres table used for PartForge state")
region = fs.String("aws-region", "", "AWS region for Postgres IAM auth; empty resolves from AWS config, then us-east-1")
postgresURL = fs.String("postgres-url", "", "Postgres state store connection URL")
Expand Down Expand Up @@ -3748,9 +3747,6 @@ func runRetryFailed(ctx context.Context, args []string) error {
if *stale && *staleAfter <= 0 {
return errors.New("stale-after must be greater than zero")
}
if *force && (*includeInProgress || *stale) {
return errors.New("force cannot be combined with include-in-progress or stale")
}
if *stale && *includeInProgress {
return errors.New("stale cannot be combined with include-in-progress")
}
Expand All @@ -3770,7 +3766,6 @@ func runRetryFailed(ctx context.Context, args []string) error {
}
retryParts, err := selectRetryParts(jobParts, retryPartSelection{
All: *all,
Force: *force,
IncludeInProgress: *includeInProgress,
Stale: *stale,
StaleAfter: *staleAfter,
Expand All @@ -3784,9 +3779,7 @@ func runRetryFailed(ctx context.Context, args []string) error {
var results []retryResult
for _, part := range retryParts {
var target state.Status
if *force {
target, err = stateStore.ForceRetryPart(ctx, part, time.Now().UTC())
} else if *stale {
if *stale {
target, err = stateStore.RetryStaleInProgressPart(ctx, part, time.Now().UTC())
} else if part.Status == state.StatusInProgress {
target, err = stateStore.RetryInProgressPart(ctx, part, time.Now().UTC())
Expand All @@ -3805,7 +3798,6 @@ func runRetryFailed(ctx context.Context, args []string) error {

out := retryFailedOutput{
JobID: *jobID,
Forced: *force,
Stale: *stale,
StaleAfter: staleAfterString(*stale, *staleAfter),
Retried: len(results),
Expand Down Expand Up @@ -5039,7 +5031,6 @@ type overviewAttention struct {

type retryFailedOutput struct {
JobID string `json:"job_id"`
Forced bool `json:"forced"`
Stale bool `json:"stale,omitempty"`
StaleAfter string `json:"stale_after,omitempty"`
Retried int `json:"retried"`
Expand Down Expand Up @@ -5815,7 +5806,6 @@ func formatDurationMs(ms int64) string {

type retryPartSelection struct {
All bool
Force bool
IncludeInProgress bool
Stale bool
StaleAfter time.Duration
Expand Down Expand Up @@ -5994,9 +5984,6 @@ func selectRetryParts(parts []state.Part, selection retryPartSelection) ([]state
return selectStaleRetryParts(parts, selection.Now, selection.StaleAfter)
}
if selection.All {
if selection.Force {
return append([]state.Part(nil), parts...), nil
}
var selected []state.Part
for _, part := range parts {
if part.Status == state.StatusFailed || (selection.IncludeInProgress && part.Status == state.StatusInProgress) {
Expand All @@ -6007,9 +5994,6 @@ func selectRetryParts(parts []state.Part, selection retryPartSelection) ([]state
}
for _, part := range parts {
if part.PartID == selection.PartID {
if selection.Force {
return []state.Part{part}, nil
}
if part.Status == state.StatusFailed || (selection.IncludeInProgress && part.Status == state.StatusInProgress) {
return []state.Part{part}, nil
}
Expand Down Expand Up @@ -6324,7 +6308,6 @@ func jobPrefixFromKey(jobID, key string) (string, error) {

func printRetryResults(out *os.File, result retryFailedOutput) {
fmt.Fprintf(out, "job_id: %s\n", result.JobID)
fmt.Fprintf(out, "forced: %t\n", result.Forced)
if result.Stale {
fmt.Fprintf(out, "stale_after: %s\n", result.StaleAfter)
}
Expand Down
16 changes: 0 additions & 16 deletions cmd/partforge/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,22 +508,6 @@ func TestSelectRetryParts(t *testing.T) {
t.Fatalf("all with in-progress = %+v", allWithInProgress)
}

forced, err := selectRetryParts(parts, retryPartSelection{All: true, Force: true})
if err != nil {
t.Fatal(err)
}
if len(forced) != 5 {
t.Fatalf("forced len = %d", len(forced))
}

forcedOne, err := selectRetryParts(parts, retryPartSelection{Force: true, PartID: "part-2"})
if err != nil {
t.Fatal(err)
}
if len(forcedOne) != 1 || forcedOne[0].PartID != "part-2" {
t.Fatalf("forced one = %+v", forcedOne)
}

one, err := selectRetryParts(parts, retryPartSelection{PartID: "part-1"})
if err != nil {
t.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ All take `-job-id`. Most use conditional updates and take `-force` where a guard

| Command | What it does |
| --- | --- |
| `retry-failed` | Move failed parts back to their retryable state. `-part-id` / `-all`; `-include-in-progress` also resets stuck workers; `-stale` (with `-stale-after`, default `5m`) resets only in-progress parts with no recent progress; `-force` re-runs even completed parts. |
| `retry-failed` | Move failed parts back to their retryable state. `-part-id` / `-all`; `-include-in-progress` also resets stuck workers; `-stale` (with `-stale-after`, default `5m`) resets only in-progress parts with no recent progress. It never touches parts in other states: use `set-part-state` to re-run one part and `reset-job` to re-run a whole job. |
| `set-part-state` | Force selected rows to a stable state (`READY`, `COMPACT_READY`, or `FINISHED`) and clear stale ownership. Select by repeated `-part-id` or by `-status`. |
| `finalize-compaction` | Finish selected `COMPACT_READY` artifacts immediately and ask compacting workers to save current useful output and finish. Select by `-all`, repeated `-part-id`, or active `-output-part-id`; requires `-force`. |
| `reset-compact-timer` | Restart the job's compact-window timer (sets `compact_ready_at` to now on every row). |
Expand Down
19 changes: 0 additions & 19 deletions internal/state/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -1940,25 +1940,6 @@ func (s *Store) RetryStaleInProgressPart(ctx context.Context, part Part, now tim
return StatusReady, nil
}

func (s *Store) ForceRetryPart(ctx context.Context, part Part, now time.Time) (Status, error) {
_, err := s.updatePart(ctx, part.JobID, part.PartID, nil, func(current *Part) error {
setStatus(current, StatusReady, now)
current.Error = ""
current.FailedAt = ""
current.StartedAt = ""
current.FinishedAt = ""
current.ImportingAt = ""
current.ImportedAt = ""
current.WorkerID = ""
clearRewriteProgress(current)
return nil
})
if err != nil {
return "", fmt.Errorf("force retry state item for %s/%s: %w", part.JobID, part.PartID, err)
}
return StatusReady, nil
}

func (s *Store) ForceSetPartStatus(ctx context.Context, part Part, to Status, now time.Time) error {
if err := validatePart(part); err != nil {
return err
Expand Down
Loading