Skip to content

The filename-alt cleanup can't overwrite an edit saved while it runs - #1418

Merged
dschmura merged 2 commits into
mainfrom
action-text-cleanup-locks
Oct 16, 2026
Merged

dschmura merged 2 commits into
mainfrom
action-text-cleanup-locks

Conversation

@dschmura

Copy link
Copy Markdown
Owner

bin/rails action_text:clear_filename_alts parsed the body find_each
had loaded and wrote it back with update_column. A rich text saved between
that read and the write lost its newer body, silently: update_column
skips the timestamp, so nothing showed the edit was gone. The task is meant
to run once on a live deployment with pre-1.0 Lexxy content, which is where
someone may be editing.

Each row is now cleaned inside with_lock, which reloads it under the
write lock (SQLite's IMMEDIATE transaction) before it is parsed. A row with
nothing to change commits an empty transaction; DRY_RUN still writes
nothing.

A new example yields a row loaded before an author's edit and asserts the
edit survives. It fails on main with the stale body written back.

Found by Copilot's review of the MClassrooms sync
(lsa-mis#119).

Verify

  • spec/tasks/action_text_spec.rb: 7 examples, 0 failures.
  • Pre-push bin/parallel-rspec: 6049 examples, 0 failures.

clear_filename_alts parsed the body find_each loaded and wrote it back with
update_column, so a rich text saved between that read and the write lost
the newer body, silently and with no timestamp change. Each row is now
cleaned inside with_lock, which reloads it under the write lock (SQLite's
IMMEDIATE transaction) before it is parsed.
@dschmura
dschmura merged commit b347698 into main Oct 16, 2026
16 checks passed
@dschmura
dschmura deleted the action-text-cleanup-locks branch October 16, 2026 17:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant