Feature request: cancel an in-progress schema alter (alter is replayed from zero on restart and blocks writes for hours)
Summary
There is no way to cancel an in-progress schema alter (PATCH /collections/:name). On a large collection an alter can run for many hours, and while it runs writes are blocked. Restarting the node does not help: the alter is replayed from the Raft log and starts again from zero. The only escape we found is restarting with --skip-writes, which also discards every other write that is not yet in a snapshot.
We would like a supported way to cancel (or at least inspect) a running schema change.
Environment
- Typesense 30.1, single node (non-production environment)
- Collection with ~1.8M documents,
enable_nested_fields: true, including auto-embedding fields (ts/paraphrase-multilingual-mpnet-base-v2, CPU)
What happened
- An alter was issued against the ~1.8M-document collection.
GET /operations/schema_changesshowed validation complete and alter progress of roughly 2,000 docs/minute. At that rate it would need about 15 hours:[{"alter_history": [], "altered_docs": 344000, "collection": "<collection>", "validated_docs": 1810236}]- While the alter was running, writes to other collections on the same node were also blocked, not only writes to the altered collection:
/stats.jsonreportedpending_write_batches: 10, unchanged for 10+ minutes.POST /collections(creating an unrelated, new collection) andDELETE /collections/<unrelated-name>timed out.- Reads and searches kept working.
- We restarted the node. The alter was replayed from the log and restarted from zero (
altered_docswent from ~344000 back to ~22000, and validation ran again). The write queue stayed blocked.
Expected / requested
- A cancel endpoint, e.g.
DELETE /operations/schema_changes/:collectionorPOST /operations/schema_changes/:collection/cancel. It would stop the alter, roll back any partially applied field changes, and record the cancellation in the Raft log so the alter is not replayed on restart. - Clarify the blocking scope. The docs say writes to the affected collection are blocked. We observed writes to unrelated collections (including create/delete collection) blocked as well. Either this is a bug, or the docs should say that the whole write path is blocked.
- Resume instead of restart. After a node restart the alter should resume from its progress rather than starting over. Otherwise cancellation should be possible before the replay.
- More detail from
/operations/schema_changes.alter_historywas empty. Seeing which fields are being changed and when the alter started would make it much easier to find what triggered a long-running alter. - (Optional) A warning or guard when an alter adds an auto-embedding field to a large collection, since that implies computing embeddings for every document while writes are blocked.
Workaround we found
Server configuration documents --skip-writes, which skips replaying writes from the Raft log. It works as an emergency stop, but it also drops every other write that is not yet in a snapshot. That is too blunt for "cancel this one alter", which is why a first-class cancel would help.
Source: typesense/typesense