# MongoServerError：时间序列桶过早关闭：最小时间小于meta.maxTime的桶已关闭

- **ID:** `mongodb/timeseries-bucket-closing-too-early`
- **领域:** mongodb
- **类别:** data_error
- **错误码:** `546`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

由于timeField或metaField配置错误，时间序列桶被过早关闭，导致数据被插入到已关闭的桶中。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| mongodb 7.0 | active | — | — |
| mongodb 6.0 | active | — | — |

## 解决方案

1. ```
   修正集合架构中的timeField和metaField：db.createCollection('sensor_data', { timeseries: { timeField: 'timestamp', metaField: 'sensor_id', granularity: 'seconds' } })
   ```
2. ```
   使用与数据频率匹配的桶粒度（例如，对于每小时数据使用'hours'）以防止过早关闭。
   ```

## 无效尝试

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