Error
Error Code:
160
MongoDB Error 160: Invalid Max Staleness Value
Description
This error indicates that the `maxStalenessSeconds` value specified in a read preference is invalid or out of an acceptable range. It commonly occurs when configuring client read preferences for replica sets, preventing the driver from properly selecting eligible secondary members for reads.
Error Message
Max Staleness Out Of Range
Known Causes
3 known causesInvalid `maxStalenessSeconds` Value
The configured `maxStalenessSeconds` is a non-positive integer (0 or negative) or an excessively large number, which MongoDB does not accept.
`maxStalenessSeconds` Too Low
The `maxStalenessSeconds` value is set below the replica set's `heartbeatIntervalMillis` (typically 10 seconds), making accurate staleness calculation impossible.
Incompatible Read Preference Mode
Using `maxStalenessSeconds` with read preference modes like `primary` or `primaryPreferred` can cause conflicts as it's only relevant for secondary selection.
Solutions
Coming SoonGeneral Troubleshooting Tips
- Check the error message carefully for specific details
- Review recent changes that might have caused the error
- Search for the exact error code in the official documentation
- Check log files for additional context
- Try restarting the application or service