发布管理:maintenanceSummary 只看 job.state === 'failed' 就给 held 处置文案; 窗口已 released 的旧作业(libsync-internal-1793399248431728863)因此自相矛盾。 改为仅 held 时给 recoveryError,已释放时给 releasedFailure(如实记录失败,不提供强制成功)。 版本记录:LoadVersionHistorySyncState 把可空的 finished_at 扫进 time.Time; 部署重启触发的同步在"进行中"时该列为 NULL,扫描失败使整页 500 (nginx access log:GET /api/v1/version-history?limit=30 → 500,74 字节错误体)。 改为指针接值再判空。前端同时区分"未配置/加载失败"并显示服务端 code。 RED/GREEN:新增 Go 集成用例(NULL finished_at)、两条前端用例; make verify 16/16 通过(local 档案)。
This commit is contained in:
@@ -171,11 +171,14 @@ WHERE repo_key = $1 AND status = 'completed' ORDER BY id DESC LIMIT 1`, repoKey)
|
||||
func (s *Store) LoadVersionHistorySyncState(ctx context.Context, repoKey string) (governance.VersionHistorySyncRun, error) {
|
||||
var run governance.VersionHistorySyncRun
|
||||
var expected *int
|
||||
// finished_at 在"进行中"的 run 上是 NULL(列可空)。用指针接再判空:
|
||||
// 直接扫进 time.Time 会让整页 500,而部署重启本身就会触发一次同步。
|
||||
var finishedAt *time.Time
|
||||
err := s.db.QueryRow(ctx, `
|
||||
SELECT id, job_id, status, source_head_sha, started_at, finished_at, complete,
|
||||
fetched_count, expected_count, error_code, triggered_by
|
||||
FROM version_history_sync_runs WHERE repo_key = $1 ORDER BY id DESC LIMIT 1`, repoKey).
|
||||
Scan(&run.ID, &run.JobID, &run.Status, &run.SourceHeadSHA, &run.StartedAt, &run.FinishedAt,
|
||||
Scan(&run.ID, &run.JobID, &run.Status, &run.SourceHeadSHA, &run.StartedAt, &finishedAt,
|
||||
&run.Complete, &run.FetchedCount, &expected, &run.ErrorCode, &run.TriggeredBy)
|
||||
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
|
||||
return governance.VersionHistorySyncRun{}, fmt.Errorf("查询同步状态:%w", err)
|
||||
@@ -183,6 +186,9 @@ FROM version_history_sync_runs WHERE repo_key = $1 ORDER BY id DESC LIMIT 1`, re
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return governance.VersionHistorySyncRun{}, nil
|
||||
}
|
||||
if finishedAt != nil {
|
||||
run.FinishedAt = *finishedAt
|
||||
}
|
||||
run.ExpectedCount = expected
|
||||
if snapshot, err := s.ActiveVersionHistorySnapshot(ctx, repoKey); err != nil {
|
||||
return governance.VersionHistorySyncRun{}, err
|
||||
|
||||
Reference in New Issue
Block a user