fix: keep render filing retryable and writers out of a folder another index moved
Third fix round of owner review 2, phase 4a (Reorganize), cross-cutting items. - Server render filing now runs under the sequence lease, so it can meet a busy sequence or an offline archive. Both completions (client render uploads and render-node results) used to answer 500 and leave the upload stuck in Committing until a restart. They now answer 503 sequence_busy or archive_offline, which clients retry. The upload goes back to receiving with its part file and the node keeps its job (UploadService.ReceiveAgainAsync). - Save both: when this PC's copy cannot be written (another index moved the folder), the server's version is no longer applied, even if this index's scan relocates the row before the apply would run. A copy that has to be dropped is deleted from where the folder is now, as a best effort. - Export rebase on a folder move (scan and Reorganize): the sequence's own export follows the folder unless its file is still at the old path and not at the new one. A file written into a re-created old folder therefore keeps a row that finds it, so the file is never stranded. - A render job refuses to start when its folder is not where the index has it, which also stops it from re-creating the old folder. Renders fetched by sync are now filed under the sequence lease into the current folder, or not at all (new string Errors.Archive.FolderMoved, en and it). - The proxy pass holds the thumbnail lease one batch at a time (a quarter of the lease wait), then lets it go for longer than a waiter's poll and reads the folder and sidecar again. Before, another process's Reorganize, sequence deletion or pack compaction could wait out its lease wait and fail. Updated the stale comments on that lease and ARCHITECTURE.md to match. Tests cover each fix, and each new test fails with its fix reverted. Also covered: proxy store and pass in a moved folder, RenderStore with the folder gone, Take server with the folder moved, and an editor save with the folder moved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 811509d32a118ed50ad10d47d4b002e534da9d77)
This commit is contained in:
1 parent
0377040a19
commit
c3756d03c9
26 files changed
+666
-134
No files matched your search
@@ -48,17 +48,19 @@ public sealed class RenderRepository
|
||||
/// <summary>
|
||||
/// Rewrites the archive-relative output paths of an archive's renders after the folder of sequence
|
||||
/// <paramref name="sequenceId"/> moved (a Reorganize, or a move another index of the archive or the user made, which a
|
||||
/// scan finds): an export inside the folder moved with it. The sequence's own exports there follow it, and so does an
|
||||
/// export of another sequence saved inside it (through the Export folder picker) when <paramref name="moved"/> says its
|
||||
/// file moved with it: a sequence that took the old folder since (a later Reorganize another index made) keeps its own.
|
||||
/// Outputs elsewhere (absolute paths, other folders) stay as they are.
|
||||
/// scan finds): an export inside the folder moved with it. Each render under the old folder whose file
|
||||
/// <paramref name="follows"/> the folder takes the new path: the caller tells the sequence's own exports there (which
|
||||
/// follow unless their file stayed behind) from an export of another sequence saved inside it through the Export
|
||||
/// folder picker (which follows only when its file moved with the folder: a sequence that took the old folder since, by
|
||||
/// a later Reorganize another index made, keeps its own). Outputs elsewhere (absolute paths, other folders) stay as they are.
|
||||
/// </summary>
|
||||
/// <param name="moved">Whether the file at the first archive-relative path is at the second one now.</param>
|
||||
/// <param name="follows">Whether the render at the first archive-relative path follows to the second one; the third
|
||||
/// argument says whether it is one of the sequence's own.</param>
|
||||
/// <remarks>Only paths still under <paramref name="oldFolder"/> change, so repeating it after a crash is harmless.</remarks>
|
||||
public async Task<int> RebaseFolderAsync(Guid archiveId, Guid sequenceId, string oldFolder, string newFolder, Func<string, string, bool> moved,
|
||||
public async Task<int> RebaseFolderAsync(Guid archiveId, Guid sequenceId, string oldFolder, string newFolder, Func<string, string, bool, bool> follows,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(moved);
|
||||
ArgumentNullException.ThrowIfNull(follows);
|
||||
// The archive root never moves, and its prefix ("/") would match absolute paths outside the archive.
|
||||
if (oldFolder.Length == 0) return 0;
|
||||
// substr counts characters (code points) on both dialects.
|
||||
@@ -71,7 +73,7 @@ public sealed class RenderRepository
|
||||
foreach (var (id, owner, path) in under)
|
||||
{
|
||||
var to = newFolder.Length == 0 ? path[prefix.Length..] : newFolder + path[oldFolder.Length..];
|
||||
if (owner != sequenceId && !moved(path, to)) continue;
|
||||
if (!follows(path, to, owner == sequenceId)) continue;
|
||||
rebased += await _db.ExecuteAsync("UPDATE renders SET output_path = $2 WHERE id = $1", [id, to], cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
return rebased;
|
||||
|
||||
Reference in new issue
Block a user