# MongoServerError: time series bucket closing too early: bucket with min time < meta.maxTime already closed

- **ID:** `mongodb/timeseries-bucket-closing-too-early`
- **Domain:** mongodb
- **Category:** data_error
- **Error Code:** `546`
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Time series bucket was closed prematurely due to a misconfigured timeField or metaField, causing data to be inserted into an already closed bucket.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| mongodb 7.0 | active | — | — |
| mongodb 6.0 | active | — | — |

## Workarounds

1. **Correct the timeField and metaField in the collection schema: db.createCollection('sensor_data', { timeseries: { timeField: 'timestamp', metaField: 'sensor_id', granularity: 'seconds' } })** (90% success)
   ```
   Correct the timeField and metaField in the collection schema: db.createCollection('sensor_data', { timeseries: { timeField: 'timestamp', metaField: 'sensor_id', granularity: 'seconds' } })
   ```
2. **Use a bucket granularity that matches data frequency (e.g., 'hours' for hourly data) to prevent premature closing.** (80% success)
   ```
   Use a bucket granularity that matches data frequency (e.g., 'hours' for hourly data) to prevent premature closing.
   ```

## Dead Ends

- **** — The same misconfiguration will cause the error again. (85% fail)
- **** — The error is about closing logic, not span; incorrect metaField is the root cause. (90% fail)
