mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-07 16:16:37 +08:00
autoresearch iter 14: stop a cache read error from clobbering the buffered task log
AppendTaskExecutionLog discarded the error from its read of the buffer, so a transient cache failure looked like an empty buffer and the very next write replaced the whole accumulated log with just the newest line. Flush already distinguished miss from failure; append now does the same.
This commit is contained in:
@@ -125,7 +125,13 @@ func AppendTaskExecutionLog(ctx context.Context, taskID, logLine string) error {
|
||||
key := TaskExecutionLogRedisKey(taskID)
|
||||
|
||||
var existing string
|
||||
_ = cacheSvc.Get(ctx, key, &existing)
|
||||
if err := cacheSvc.Get(ctx, key, &existing); err != nil {
|
||||
// 只有未命中才代表「尚无缓冲」;其余读取失败若被当作空缓冲继续写入,
|
||||
// 会用这一行覆盖掉整段已缓冲的任务日志。
|
||||
if !errors.Is(err, contracts.ErrCacheMiss) {
|
||||
return fmt.Errorf("load buffered task execution log: %w", err)
|
||||
}
|
||||
}
|
||||
return cacheSvc.Set(ctx, key, existing+line, taskExecutionLogExpiration)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user