# sqlalchemy.exc.InvalidRequestError: This session is in 'rolled back' state. No operations are allowed.

- **ID:** `python/sqlalchemy-session-rollback-error`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Attempting to use a session after a rollback without beginning a new transaction.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **Begin a new transaction after rollback.** (95% success)
   ```
   session.rollback()
session.begin()  # Start new transaction
   ```
2. **Use session.begin() context manager to auto-handle rollback.** (90% success)
   ```
   with session.begin():
    session.add(obj)
# Automatically commits or rolls back
   ```

## Dead Ends

- **Calling session.commit() after rollback.** — Session is in invalid state; must begin new transaction. (90% fail)
- **Ignoring rollback and continuing.** — Session remains in aborted state; all operations fail. (80% fail)
