cddc4c90d1
- platform/postgres: listTestPublicationsSQL 的 can_start/can_retry 在 LEFT JOIN
内容对象为空时算出 NULL,Go 侧 bool 扫描失败使整个列表接口 500,前端三个 lane
全空(表现为“待入库 0 / 全部任务 0”)。改为 COALESCE(..., false)。
- 新增 POST /api/v1/job-failures/{id}/requeue:取件任务的幂等键绑在版本上,
失败那次已占住它,重新标注同一文件不会再入队;现在按新轮次 (…:r<n>) 重排、
复位意图取件状态并把死信标记为 requeued(幂等信封 + 审计字段)。
- web: 死信区对 artifact.fetch 显示「重新入队」;系统设置新增「知识库绑定」分区,
挂上一直没被渲染的 RoutingBindingsSection,导入目标库可在页面上切换。
- 测试:真实 PostgreSQL 集成测试(NULL 折叠 + 重排轮次/幂等/拒绝)、前端死信按钮
与设置分区渲染测试。
106 lines
3.8 KiB
Go
106 lines
3.8 KiB
Go
package governance
|
|
|
|
import "time"
|
|
|
|
// JobFailure is one terminal-attempt dead-letter projection (P6). It never
|
|
// replaces the original jobs audit row; it points at it.
|
|
type JobFailure struct {
|
|
ID string `json:"id"`
|
|
JobID string `json:"job_id"`
|
|
JobType string `json:"job_type"`
|
|
PublicationID string `json:"publication_id,omitempty"`
|
|
SourceItemID string `json:"source_item_id,omitempty"`
|
|
ErrorCode string `json:"error_code"`
|
|
Attempt int `json:"attempt"`
|
|
MaxAttempts int `json:"max_attempts_at_failure"`
|
|
ChangeSetID string `json:"change_set_id,omitempty"`
|
|
Action string `json:"action,omitempty"`
|
|
TargetKBID string `json:"target_kb_id,omitempty"`
|
|
State string `json:"state"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
DocName string `json:"doc_name,omitempty"`
|
|
LastError string `json:"last_error,omitempty"`
|
|
}
|
|
|
|
type JobFailureFilter struct {
|
|
State string // open | requeued | abandoned | "" (defaults to open)
|
|
Limit int
|
|
Offset int
|
|
}
|
|
|
|
type JobFailurePage struct {
|
|
Items []JobFailure `json:"items"`
|
|
Total int `json:"total"`
|
|
Limit int `json:"limit"`
|
|
Offset int `json:"offset"`
|
|
}
|
|
|
|
const (
|
|
RetryStarted = "started"
|
|
RetryAlreadyRunning = "already_running"
|
|
RetryNotRetryable = "not_retryable"
|
|
)
|
|
|
|
// RetryPublicationsBatchRequest is the server-side batch retry (P6): one
|
|
// atomic operation covering 1..100 publications with per-item outcomes.
|
|
type RetryPublicationsBatchRequest struct {
|
|
PublicationIDs []string `json:"publication_ids"`
|
|
OperatorRef string `json:"operator_ref"`
|
|
Reason string `json:"reason"`
|
|
Now time.Time `json:"-"`
|
|
}
|
|
|
|
type RetryOutcome struct {
|
|
PublicationID string `json:"publication_id"`
|
|
Result string `json:"result"`
|
|
Detail string `json:"detail,omitempty"`
|
|
}
|
|
|
|
type RetryPublicationsBatchResult struct {
|
|
BatchKey string `json:"batch_key"`
|
|
Total int `json:"total"`
|
|
Started int `json:"started"`
|
|
AlreadyRunning int `json:"already_running"`
|
|
NotRetryable int `json:"not_retryable"`
|
|
Outcomes []RetryOutcome `json:"outcomes"`
|
|
}
|
|
|
|
// CancelOutcome constants reuse the retry vocabulary plus "cancelled".
|
|
const (
|
|
CancelCancelled = "cancelled"
|
|
)
|
|
|
|
// CancelPublicationsBatchRequest is the operator's "stop retrying" batch:
|
|
// 1..100 failed/stalled publications move to 'cancelled', their queued
|
|
// upload jobs are dropped and their open dead letters are abandoned.
|
|
// Source records and spooled artifacts are untouched; re-marking the file
|
|
// in 来源与目录 can still create a fresh publication later.
|
|
type CancelPublicationsBatchRequest struct {
|
|
PublicationIDs []string `json:"publication_ids"`
|
|
OperatorRef string `json:"operator_ref"`
|
|
Reason string `json:"reason"`
|
|
Now time.Time `json:"-"`
|
|
}
|
|
|
|
// RequeueArtifactFetchRequest re-enqueues ONE terminal 源头取件 (artifact.fetch)
|
|
// dead letter. The fetch job's idempotency key is derived from the version
|
|
// ("artifact-fetch:<version_id>"), and the failed attempt permanently occupies
|
|
// it — so a plain re-mark of the same file resolves to the same version and its
|
|
// ON CONFLICT DO NOTHING insert is silently swallowed. A requeue therefore opens
|
|
// a new ROUND ("...:r<n>") instead of replaying the original key.
|
|
type RequeueArtifactFetchRequest struct {
|
|
FailureID string
|
|
OperatorRef string
|
|
Reason string
|
|
Now time.Time
|
|
}
|
|
|
|
type RequeueArtifactFetchResult struct {
|
|
FailureID string `json:"failure_id"`
|
|
JobID string `json:"job_id"`
|
|
VersionID string `json:"version_id"`
|
|
Round int `json:"round"`
|
|
DocName string `json:"doc_name,omitempty"`
|
|
AlreadyQueued bool `json:"already_queued"`
|
|
}
|