fix(session-coordinator): 修复 FindExpired SQL 时区问题

- expires_at 存储为 UTC 时间
- 查询时使用 NOW() AT TIME ZONE 'UTC' 确保时区一致
- 避免因时区差异导致 session 过早被标记为过期

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-29 10:07:28 -08:00
parent e222279d77
commit a22fc16313
1 changed files with 2 additions and 1 deletions

View File

@ -207,13 +207,14 @@ func (r *SessionPostgresRepo) FindByStatus(ctx context.Context, status value_obj
}
// FindExpired retrieves all expired but not yet marked sessions
// Note: expires_at is stored in UTC, so we compare with NOW() AT TIME ZONE 'UTC'
func (r *SessionPostgresRepo) FindExpired(ctx context.Context) ([]*entities.MPCSession, error) {
rows, err := r.db.QueryContext(ctx, `
SELECT id, session_type, threshold_n, threshold_t, status,
message_hash, public_key, delegate_party_id, keygen_session_id, created_by, created_at, updated_at, expires_at, completed_at, version,
COALESCE(wallet_name, ''), COALESCE(invite_code, '')
FROM mpc_sessions
WHERE expires_at < NOW() AND status IN ('created', 'in_progress')
WHERE expires_at < (NOW() AT TIME ZONE 'UTC') AND status IN ('created', 'in_progress')
`)
if err != nil {
return nil, err