Catalogue / pythonanywhere-2024-file-server-migration

PythonAnywhere swaps a file server to newer hardware on schedule, then finds stuck SQLite locks and unbalanced always-on tasks

PythonAnywhere, 2024. File servers and always-on task cluster.

Organisation
PythonAnywhere
Evidence
Incident report
System
File servers and always-on task cluster
Setup
Sharded

Near: affecting only those accounts on the server

As of
2024-09
Source
Issues after system maintenance on 2024-09-05

PythonAnywhere blog, published 2024-09-10

Architecture

Users' accounts are spread over a number of file servers, each with a lock manager process that tracks which files are locked. Old file servers run on m3-series AWS instances and newer ones on m5-series with a different Ubuntu version. A separate cluster of nodes runs users' always-on tasks.

Section: Why was the maintenance necessary? | Section: Sub-timeline: SQLite | Near: making sure that each node had the same

Figures, as the source states them

FigureAs statedNoteWhere
Website-issue reports received from 06:20 to 10:10 UTC10 reportsAround tenNear: We received around ten

Records

Decision#d1

Move file servers to newer instances by syncing in the background and swapping in a short maintenance window

pythonanywhere-2024-file-server-migration#d1 at corpus version 26a1b3a7e3dd
Chosen

Each old m3 file server syncs all of its data to a new m5 one in the background, and the only downtime is at the end, when the servers are swapped so the m5 becomes primary. The first swap on the main US system was done for one file server only, livefile10.

Near: So our process has been to set | Near: It was just one of the file servers

Rejected

Copy the data from one machine to another directly. It would take days to weeks, and users on those file servers could do nothing while the copy ran, which the team considers unacceptable.

Near: Simply copying the data from one machine

What forced it

Over the previous year the team had noticed degraded reliability in the m3-series instances used as file servers, and found that moving to m5-series instances improves it significantly. AWS support told them there were no known issues with the type.

Near: we have noticed degraded reliability in certain

Reasoning

Syncing in the background keeps accounts usable while the data moves, which a direct copy lasting days to weeks would not. Only one file server was switched first because the team wanted to minimise issues if the process had a problem. The same switchover had already been done on the EU system and in numerous test environments without any issues.

Section: Why was the maintenance necessary?

What worked before

File servers had been running on m3-series instances; since February newly created file servers had used m5 instances, and the old ones still held data to be migrated.

Near: Newly-created file servers have, since February,

Outcome

The switchover started at 06:00 UTC and systems were back at 06:20, the scheduled time, with all files present on the new server. Later that day stuck SQLite locks and overloaded always-on task nodes appeared as knock-on effects.

Section: Thursday, 5 September | Section: Sub-timeline: SQLite | Section: Sub-timeline: Always-on tasks

Failure#f1

SQLite databases locked when maintenance began stayed locked afterwards, and old file servers had to be rebooted

pythonanywhere-2024-file-server-migration#f1 at corpus version 26a1b3a7e3dd
Trigger

The file server switchover began at 06:00 UTC on 5 September 2024, with the site and hosted sites brought down. SQLite databases that were locked for updates at that moment did not have their locks cleared.

Section: Thursday, 5 September | Near: had not had those locks cleared

How it failed

Any code that used one of those databases hung, so websites using SQLite stopped working, on various file servers and not only the migrated one. Restarting the lock manager released the locks on the new-style m5 servers but not on the old m3 servers, which the team believes is down to their different Ubuntu versions; those released locks only on reboot.

Section: Sub-timeline: SQLite

Why defences did not hold

The same switchover had run cleanly on the EU system and in test environments. Around ten reports of broken websites arrived between 06:20 and 10:10, but different people handled different cases and it took a while to see the common theme; the link to SQLite was found at 11:15.

Section: In general | Near: we finally worked out the connection | Section: Why was the maintenance necessary?

Impact

Websites using affected SQLite databases hung from the maintenance until the lock managers were restarted at 11:20, or, on old-style servers, until reboots that finished by 15:00. Each reboot caused an outage of about 2-3 minutes for every account on that server, including those not using SQLite.

Section: Sub-timeline: SQLite | Section: Summary

Fix

Lock managers were restarted on all file servers at 11:20 and the old servers were rebooted one at a time between 12:45 and 15:00. In progress: looking for a way to spot patterns in support requests sooner. Planned: restart the lock managers inside the maintenance window in the next migration, either migrating a subset and rebooting the remaining old servers or migrating all remaining m3 servers in one batch; the team will test before choosing.

Section: Sub-timeline: SQLite | Section: SQLite | Section: In general

Failure#f2

Uneven task placement after maintenance caused networking problems on some always-on tasks

pythonanywhere-2024-file-server-migration#f2 at corpus version 26a1b3a7e3dd
Trigger

After the maintenance the always-on task cluster came back up. The team now believes it did so asymmetrically: some nodes returned sooner than others and started picking up tasks first.

Near: We now believe that this was because

How it failed

The team found some machines running significantly more always-on tasks than others, which it says explained why only a subset of tasks had networking problems. As the post describes it in general terms, too many tasks on one server can slow networking until, for example, DNS lookups fail and tasks cannot connect to external APIs or databases.

Section: Sub-timeline: Always-on tasks

Impact

Networking problems on a subset of always-on tasks were reported between 11:00 and 15:00 UTC on 5 September. Separately, other always-on tasks had network issues on Saturday 7 September; the team was investigating, saw no way the two could be connected, and no link is established.

Section: Sub-timeline: Always-on tasks | Section: Saturday, 7 September

Fix

Between 15:00 and 18:00 the team rebalanced the cluster by hand so each node ran the same number of tasks, which appeared to fix it. Planned: in the next migration, shut down and restart the always-on system the way a normal system update does, accepting slow task start-up. For the longer term the team is debating whether to improve the current architecture or switch to one built on systems it already uses elsewhere.

Section: Sub-timeline: Always-on tasks | Section: Always-on tasks

Decision#d2

Reboot the old file servers one at a time to clear the locks, not all together

pythonanywhere-2024-file-server-migration#d2 at corpus version 26a1b3a7e3dd
Chosen

Once it was clear that the old-style servers released their locks only on reboot, the team rebooted them one at a time between 12:45 and 15:00.

Near: we rebooted the old servers one

Rejected

Reboot the old servers as a group. The team judged that this could have led to a significantly longer outage across all sites.

Near: in a group could have led to

What forced it

SQLite databases on the old-style servers were still locked after the lock manager restart, and the team found no way other than a reboot to release them.

Near: the only way to get those servers

Reasoning

Rebooting one server was expected to cause an outage of 2-3 minutes affecting only the accounts on that server and potentially PythonAnywhere's own site.

Near: expected (correctly) to cause an outage lasting

Outcome

The single-server expectation proved correct: each reboot gave a short outage for all accounts on that server. By 15:00 the process was complete and all SQLite databases were working again.

Near: By 15:00 this process was complete | Near: expected (correctly) to cause an outage lasting

Review

Extracted by
Claude (feed 45)
Human review
Not started. Status recorded on 2026-12-02.