fix(monitors): index heartbeat token hash

This commit is contained in:
2026-09-17 09:24:42 +00:00
parent 2701b32b5f
commit cffa7e84b2
+9
View File
@@ -23,6 +23,15 @@ func EnsureMonitorServerStateIndexes() error {
if err != nil {
log.Printf("warning: monitor_server_states indexes: %v", err)
}
// Every heartbeat ping looks its monitor up by token hash. Sparse because
// only heartbeat monitors carry one.
_, err = db.Col("monitors").Indexes().CreateOne(context.Background(), mongo.IndexModel{
Keys: bson.D{{Key: "heartbeat_token_hash", Value: 1}},
Options: options.Index().SetSparse(true),
})
if err != nil {
log.Printf("warning: monitors heartbeat_token_hash index: %v", err)
}
return nil
}