# MongoServerError: Transaction aborted due to a catalog operation

- **ID:** `mongodb/transaction-aborted-due-to-catalog-operation`
- **Domain:** mongodb
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

A DDL operation (e.g., createIndex, dropCollection) was attempted on a namespace involved in an active multi-document transaction, which is not allowed.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MongoDB 4.2.24 | active | — | — |
| MongoDB 5.0.18 | active | — | — |
| MongoDB 6.0.8 | active | — | — |

## Workarounds

1. **Move DDL operations (e.g., createIndex, drop) outside the transaction session. Perform them before starting the transaction.** (90% success)
   ```
   Move DDL operations (e.g., createIndex, drop) outside the transaction session. Perform them before starting the transaction.
   ```
2. **If DDL is unavoidable, use a separate session for DDL operations and ensure they complete before the transaction starts.** (85% success)
   ```
   If DDL is unavoidable, use a separate session for DDL operations and ensure they complete before the transaction starts.
   ```

## Dead Ends

- **** — Increasing transaction timeout doesn't prevent catalog operations from aborting the transaction. (90% fail)
- **** — Retrying the same transaction without moving DDL operations outside will fail again. (95% fail)
