How to Fix MongoDB Error 290 (TransactionExceededLifetimeLimitSeconds)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mongodb error 290 when a transaction runs past its allowed lifetime limit. To fix it, speed up slow queries inside the transaction or break up big writes. In the database engine, this failure has the official name TransactionExceededLifetimeLimitSeconds. It belongs to the Interruption and ExceededTimeLimitError categories. When the timer runs out, the database aborts the open work and rolls back changes. What causes mongodb error 290 in your cluster A transaction holds locks and memo

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You get mongodb error 290 when a transaction runs past its allowed lifetime limit. To fix it, speed up slow queries inside the transaction or break up big writes.

In the database engine, this failure has the official name TransactionExceededLifetimeLimitSeconds. It belongs to the Interruption and ExceededTimeLimitError categories. When the timer runs out, the database aborts the open work and rolls back changes.

What causes mongodb error 290 in your cluster

A transaction holds locks and memory snapshots while it keeps the session active. The database enforces a strict time limit so one slow job cannot block other work. Several common issues push a transaction past this cap.

First, an app might run unindexed reads inside the transaction block. Scanning a huge collection takes too much time and burns through the clock. Second, the app might call an external web service while the transaction waits. Network delays between the app and outside systems keep the database session open too long.

Third, a worker job might pack too many document updates into a single batch. Writing thousands of records at once stresses disk storage and slows down replica communication. Lock contention from other concurrent writes can also stall the transaction until it expires.

How to diagnose and fix transaction timeouts safely

Start by checking your database logs for the TransactionExceededLifetimeLimitSeconds event. Look at the queries that ran right before the abort happened. When engineers inspect production data, keep access tight and safe. MongoDB grants access through roles that define allowed actions on specific resources. A role applies to its defined database and can control access down to one collection.

Give your debugging team the built-in read role rather than full write access. The read role allows actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It blocks insert, update, remove, and dropCollection actions on non-system collections. This lets engineers check index use and collection stats without risking accidental data changes.

MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Once you find the slow step, refactor the app logic to shrink the transaction window. Move all external network calls and heavy math outside the transaction boundary. Fetch and prepare your data before you start the transaction.

Next, add missing indexes so queries inside the transaction finish in milliseconds. Only users with the readWrite role or higher can run createIndex or modify data. If a batch job updates too many rows, split the work into smaller chunks. Commit each small batch in its own fast transaction instead of one giant run.

How to prevent future lifetime limit errors

Avoid raising the server lifetime limit as a quick fix in production. Raising the timer lets bad queries hold locks longer and hurts cluster health. Instead, set client timeouts that match your server limits and retry transient errors in code.

Keep audit trails and data masking active when developers run live diagnostics. Masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results. This protects sensitive records while engineers inspect slow query plans and fix transaction bottlenecks.

Check MongoDB commands and documents on the wire

MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB. It reads the MongoDB wire protocol and checks commands and bulk writes as JSON while passing login through untouched.

Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents that match your rules. Every command and verdict is logged. See the open-source code on GitHub.

Frequently asked questions

What does TransactionExceededLifetimeLimitSeconds mean in MongoDB?

It is the official name for error code 290 in the database engine. It means an open multi-document transaction ran longer than the server allows and got aborted.

Should I increase the transaction lifetime limit to stop error 290?

No, raising the time limit often hides slow queries and causes heavy lock contention. You should add indexes and shrink the transaction work instead of raising the timer.

What database role do engineers need to check collection stats for slow transactions?

The built-in read role is enough to inspect indexes and collection stats safely. It grants listIndexes, dbStats, and collStats actions without allowing data writes or drops.

Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.

The query runs. The emails stay hidden.