Infinite loop in Directus Flow caused ~1.5M records in custom collection, CMS unusable and collection cannot be CRUD / dropped

Hi Directus community,

I ran into a serious issue after creating a Flow with an infinite loop, which continuously created records in a custom collection for almost a day.

Current state

  • The collection now has ~1.5M records

  • Directus Admin UI is accessible again, but:

    • :cross_mark: Cannot CRUD this collection

    • :cross_mark: Cannot drop it from Data Model

    • :cross_mark: API requests time out

  • Other collections work normally

The Flow is already disabled, but the collection is completely unusable.

Main question

:backhand_index_pointing_right: What is the correct and the way to drop this collection?

Heya!

Oof, that’s a rough one :grimacing:

The UI and API are timing out because your database server is likely a bit underpowered to handle that volume of records. Your best bet is to go directly to the database:

  1. Connect to your DB directly (e.g. through a CLI client or something like pgAdmin/phpMyAdmin depending on your DB)
  2. Drop the table: `DROP TABLE your_collection_name;`
  3. Clean up the Directus system tables so it doesn’t try to reference the now-gone collection:
DELETE FROM directus_fields WHERE collection = 'your_collection_name';
DELETE FROM directus_relations WHERE many_collection = 'your_collection_name' OR one_collection = 'your_collection_name';
DELETE FROM directus_collections WHERE collection = 'your_collection_name';
DELETE FROM directus_permissions WHERE collection = 'your_collection_name';
  1. Restart Directus after

If you’d rather keep the collection but just nuke the data, you could TRUNCATE your_collection_name; instead of dropping the whole table in step 2, and skip step 3.

If you’re using Directus Cloud, our support team can help you out as well → support@directus.io

As for the flow, I’d recommend adding a condition or limit check to prevent runaway loops in the future. There’s no built-in execution cap on flows currently.