Skip to content

Studio: Fix site deletion lock contention for multiple deletions - #2492

Merged
epeicher merged 3 commits into
trunkfrom
stu-1266-ensure-it-is-possible-to-delete-multiple-sites-in-succession
Jan 28, 2026
Merged

Studio: Fix site deletion lock contention for multiple deletions#2492
epeicher merged 3 commits into
trunkfrom
stu-1266-ensure-it-is-possible-to-delete-multiple-sites-in-succession

Conversation

@epeicher

@epeicher epeicher commented Jan 28, 2026

Copy link
Copy Markdown
Contributor

Related issues

Root Cause

When deleting a site, both the main process and CLI tried to lock and update the same appdata-v1.json.lock file:

Main process acquires lock → spawns CLI
CLI tries to acquire the same lock → blocked
CLI waits 5 seconds for lock to become "stale", then takes over
Single site: Hidden 5-second delay on every deletion

Multiple sites: Race condition when multiple processes try to take over the stale lock simultaneously → EEXIST errors → deletion failures

Proposed Changes

  • Fixed site deletion lock contention that caused failures when deleting multiple sites in succession
  • Removed redundant appdata locking from the main process deleteSite handler
  • The CLI already handles appdata updates with proper locking, so the main process lock was causing a deadlock
  • Also removes the hidden 5-second delay that occurred during single site deletion while waiting for the lock to become stale

Testing Instructions

  • Create multiple test sites in Studio. I use the studio cli for that by moving to ~/Studio folder and running:
for n in 1 2 3 4 5 6 7 8 9 0; do studio site create --path="site-number-$n" --skip-browser --skip-log-details; done
  • Delete them one after another in quick succession
  • Verify all sites are deleted successfully without errors
  • No "appdata-v1.json" locking error should appear
  • Single site deletion should complete without delays

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
…iple sites

Remove appdata locking from the main process deleteSite handler. The CLI
process already handles appdata updates with proper locking, so the main
process locking was redundant and caused lock contention issues.

When deleting multiple sites, the main process would hold the lock while
spawning CLI processes that also needed the same lock, causing race conditions
and EEXIST errors in the lockfile package's stale-lock recovery mechanism.
@epeicher epeicher self-assigned this Jan 28, 2026
@epeicher
epeicher requested a review from a team January 28, 2026 12:28
@epeicher
epeicher marked this pull request as ready for review January 28, 2026 12:28
…sure-it-is-possible-to-delete-multiple-sites-in-succession
@wpmobilebot

wpmobilebot commented Jan 28, 2026

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 7424f58 vs trunk

site-editor

Metric trunk 7424f58 Diff Change
load 2870.00 ms 2892.00 ms +22.00 ms 🔴 0.8%

site-startup

Metric trunk 7424f58 Diff Change
siteCreation 7103.00 ms 7076.00 ms -27.00 ms 🟢 -0.4%
siteStartup 3920.00 ms 3925.00 ms +5.00 ms 🔴 0.1%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change

…sure-it-is-possible-to-delete-multiple-sites-in-succession

@bcotrim bcotrim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch and cleanup! @epeicher
Works as described
LGTM 👍

@epeicher
epeicher merged commit 577a9ce into trunk Jan 28, 2026
9 checks passed
@epeicher
epeicher deleted the stu-1266-ensure-it-is-possible-to-delete-multiple-sites-in-succession branch January 28, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants