Kiryl
6a45e8c8d1
feat: log migration progress and heartbeat ( #31789 )
...
Migrations run at server startup with no output, so admins can't tell
which migration is running, whether it waits on a lock, or how far it
got.
This adds a reporter to the migration driver. It logs:
- the pending migrations, and each step with its position and duration;
- the migration lock (debug level);
- a heartbeat every 10s during a lock wait or a long step, with the
connection state from `pg_stat_activity` and the blocking sessions.
The migration transaction is named `coder-migrate/<version>`, so other
instances and admins can see it. Heartbeat queries run on their own
connection and never delay the migration.
API: `Up(db, opts...)`, with `WithFS` (replaces `UpWithFS`) and
`WithLogger`. Without a logger, nothing is logged. Server startup turns
it on in #31790 .
```
[info] database migration required from_version=1 target_version=3 pending=2
[info] applying database migration version=3 name=step_3 position=2 total=2
[info] still applying database migration elapsed_ms=1000 state=waiting_on_lock wait_event=relation blocked_by=[blocker] version=3 name=step_3 position=2 total=2
[info] database migration applied, pending commit version=3 name=step_3 position=2 total=2 duration_ms=1000
```
Tests compare log output with golden files in
`coderd/database/migrations/testdata/reporter`.
Closes ENT-235
_Written with Claude Code and Coder Agents, reviewed and tested by
@kirstaeff._
2026-11-23 12:52:00 +01:00
..
2026-11-13 21:34:59 +00:00
2026-11-20 19:02:08 +03:00
2026-11-04 17:15:42 -05:00
2026-10-14 16:34:56 +05:00
2026-11-20 13:43:07 -06:00
2026-01-08 15:24:11 +04:00
2026-03-12 13:39:24 -06:00
2026-10-27 17:36:23 +00:00
2026-11-20 19:02:08 +03:00
2025-06-20 13:16:55 -06:00
2026-09-29 14:24:00 -07:00
2026-11-13 21:34:59 +00:00
2026-09-29 11:48:53 +02:00
2026-09-29 09:20:31 +01:00
2026-09-18 16:47:16 +02:00
2026-09-29 20:07:49 +01:00
2025-10-27 17:07:25 +01:00
2026-10-08 11:55:29 -04:00
2026-10-29 11:07:10 +01:00
2024-08-22 15:40:53 +10:00
2026-11-05 10:01:33 +05:00
2026-05-13 14:59:33 -05:00
2026-11-05 10:19:38 +05:00
2026-06-02 10:46:40 +00:00
2026-11-05 10:19:38 +05:00
2026-01-08 15:24:11 +04:00
2026-01-08 15:24:11 +04:00
2026-09-30 14:18:26 -04:00
2026-11-05 10:19:38 +05:00
2026-11-05 10:19:38 +05:00
2026-06-03 15:30:37 -04:00
2026-04-27 12:58:26 +01:00
2025-03-04 15:37:29 -07:00
2025-03-04 15:37:29 -07:00
2025-03-04 15:37:29 -07:00
2026-01-08 15:24:11 +04:00
2026-11-04 15:18:08 -05:00
2026-11-04 15:18:08 -05:00
2026-11-04 15:18:08 -05:00
2026-06-22 19:26:34 -06:00
2026-06-22 12:15:27 -06:00
2026-10-21 06:28:45 -07:00
2025-06-20 13:16:55 -06:00
2025-03-26 01:56:39 -05:00
2026-11-11 23:54:05 +01:00
2026-10-29 20:32:56 +01:00
2026-10-14 16:34:56 +05:00
2026-10-14 16:34:56 +05:00
2026-03-05 09:35:57 -08:00
2026-10-12 15:56:40 +03:00
2026-10-02 16:40:24 -08:00
2026-09-28 09:42:31 -05:00
2026-08-26 18:46:34 +02:00
2026-10-27 12:34:18 -07:00
2026-08-25 12:45:02 -07:00
2026-05-15 14:36:54 -07:00
2026-09-18 11:57:06 -07:00
2026-08-04 16:24:14 +10:00
2026-09-18 11:57:06 -07:00
2026-04-29 10:28:27 -07:00
2026-05-15 14:36:54 -07:00
2026-01-08 15:24:11 +04:00
2026-09-18 11:57:06 -07:00
2026-09-28 09:42:31 -05:00
2026-09-14 14:33:36 +01:00
2026-09-14 15:43:16 +01:00
2026-07-07 12:38:37 -07:00
2026-07-07 12:38:37 -07:00
2026-01-08 15:24:11 +04:00
2026-10-29 11:07:10 +01:00
2026-09-29 22:27:30 +00:00
2026-09-29 22:27:30 +00:00
2026-06-03 15:30:37 -04:00
2026-03-02 22:52:39 -05:00
2026-06-03 15:16:42 -04:00
2025-09-03 10:49:19 +04:00
2026-09-28 09:42:31 -05:00
2026-09-28 09:42:31 -05:00
2025-03-26 01:56:39 -05:00
2026-11-20 19:02:08 +03:00
2026-09-23 19:42:10 -06:00
2026-09-23 19:42:10 -06:00
2026-04-21 15:11:50 -05:00
2026-11-19 20:22:21 -07:00
2026-11-20 19:02:08 +03:00
2026-06-03 15:30:37 -04:00
2026-11-20 19:02:08 +03:00
2026-01-08 15:24:11 +04:00
2026-04-27 12:58:26 +01:00
2026-06-03 15:16:42 -04:00
2026-04-16 12:46:52 -04:00
2025-09-11 15:08:57 +02:00
2026-01-08 15:24:11 +04:00
2026-07-28 16:59:33 -07:00
2026-08-26 11:57:56 -06:00
2026-11-05 09:38:12 -08:00
2026-11-11 17:14:06 +00:00
2026-11-05 09:38:12 -08:00
2026-09-30 14:57:29 -04:00
2026-09-30 13:00:38 -04:00
2026-02-05 19:35:20 +11:00
2026-02-06 14:09:39 +11:00
2026-09-30 14:57:29 -04:00
2024-08-20 14:47:46 +10:00
2026-11-13 14:33:32 -05:00
2024-05-23 07:54:59 -10:00
2026-03-25 13:11:08 +11:00
2026-03-04 11:14:52 -07:00
2026-04-24 17:09:17 -04:00
2026-02-26 14:34:30 +01:00
2026-10-28 11:00:19 -06:00
2026-10-26 13:17:51 -04:00
2026-11-05 10:19:38 +05:00
2026-11-05 10:19:38 +05:00
2026-11-23 12:12:02 +11:00
2026-11-17 14:59:18 +01:00
2026-11-23 12:12:02 +11:00
2025-10-06 08:56:43 +00:00
2025-12-03 11:32:59 +02:00
2026-03-03 08:47:34 +00:00
2025-12-03 11:32:59 +02:00
2026-01-08 15:24:11 +04:00
2025-03-26 01:56:39 -05:00
2026-10-06 10:08:14 -04:00
2026-10-29 11:07:10 +01:00
2026-09-07 15:24:33 +02:00
2026-01-08 15:24:11 +04:00
2026-08-26 11:57:56 -06:00
2026-10-07 13:17:12 -07:00
2026-11-10 14:59:49 -05:00
2026-07-08 11:12:53 +02:00
2026-11-20 19:02:08 +03:00
2025-06-20 13:16:55 -06:00
2026-10-08 13:07:17 -04:00
2026-10-08 13:07:17 -04:00
2026-07-28 14:37:29 -07:00
2026-10-15 17:40:00 -05:00
2026-10-15 17:40:00 -05:00
2026-10-05 14:00:15 +00:00
2026-09-30 12:36:05 -04:00
2026-09-30 12:36:05 -04:00
2026-06-16 13:26:04 -07:00
2026-06-23 11:37:33 -05:00
2026-06-23 11:37:33 -05:00
2026-11-20 13:43:07 -06:00
2026-06-03 15:30:37 -04:00
2026-01-08 15:24:11 +04:00
2026-11-11 11:50:16 +00:00
2026-11-23 12:52:00 +01:00
2026-11-19 20:22:21 -07:00
2026-11-19 20:22:21 -07:00
2026-06-23 11:58:00 -05:00
2026-09-30 21:29:51 +00:00
2026-11-05 10:19:38 +05:00
2026-11-05 10:19:38 +05:00
2026-06-03 15:16:42 -04:00
2026-01-08 15:24:11 +04:00
2026-11-05 10:19:38 +05:00
2026-11-05 10:19:38 +05:00
2026-11-05 10:19:38 +05:00
2026-10-07 13:17:12 -07:00
2026-10-14 08:52:36 -07:00
2026-10-13 07:57:56 +00:00
2025-03-26 10:36:53 +00:00
2026-02-23 22:46:17 -06:00
2026-04-27 12:58:26 +01:00
2026-10-14 08:52:36 -07:00
2026-07-16 13:00:32 +03:00
2026-07-16 13:00:32 +03:00
2026-11-16 13:04:58 -07:00
2025-11-28 08:33:50 +02:00
2026-06-17 13:01:57 +02:00
2025-11-28 08:33:50 +02:00
2026-05-27 12:33:39 +02:00
2026-06-17 13:01:57 +02:00
2026-09-17 19:26:18 +02:00
2026-05-14 14:45:20 +02:00
2026-06-17 13:01:57 +02:00
2026-10-15 17:46:05 +00:00
2026-10-15 17:46:05 +00:00
2026-06-03 15:30:37 -04:00
2026-01-08 15:24:11 +04:00
2026-08-06 14:45:38 +10:00
2026-10-15 17:46:05 +00:00
2026-06-02 08:05:26 -04:00
2026-03-23 23:19:23 +02:00
2026-06-03 15:30:37 -04:00
2025-12-03 11:32:59 +02:00
2026-06-03 15:30:37 -04:00
2025-12-03 11:32:59 +02:00
2026-06-03 15:30:37 -04:00
2025-09-22 17:14:07 +04:00
2026-09-08 21:45:43 -06:00
2026-11-06 19:32:46 -06:00
2025-07-24 16:44:36 +01:00
2025-12-15 11:26:41 -06:00
2025-09-22 17:14:07 +04:00
2026-06-03 15:30:37 -04:00
2026-02-19 09:31:12 +11:00
2026-11-13 12:45:32 -05:00
2026-11-13 12:45:32 -05:00
2026-10-28 11:00:19 -06:00
2026-10-14 08:52:36 -07:00
2026-10-13 07:57:56 +00:00
2026-07-28 21:05:50 +10:00
2026-07-28 21:05:50 +10:00
2025-09-22 17:14:07 +04:00
2026-09-30 12:36:30 -04:00
2026-09-30 12:36:30 -04:00
2026-09-30 12:38:45 -04:00
2026-09-30 12:38:45 -04:00
2026-03-19 15:14:00 +00:00
2026-03-18 22:10:04 +00:00
2026-03-18 22:10:04 +00:00
2026-09-30 12:38:14 -04:00
2026-09-30 12:38:14 -04:00
2025-06-20 13:16:55 -06:00
2026-08-21 23:46:27 -06:00
2025-06-20 13:16:55 -06:00
2026-01-08 15:24:11 +04:00
2026-10-06 11:52:40 -06:00
2026-02-12 12:14:56 +01:00
2026-02-12 12:14:56 +01:00
2026-02-12 12:14:56 +01:00
2026-10-06 11:52:40 -06:00
2024-11-18 21:10:01 +10:00
2026-09-19 00:32:51 +02:00
2026-10-02 16:40:24 -08:00
2026-08-05 10:42:13 -07:00
2025-09-26 11:20:25 +01:00
2026-10-14 08:52:36 -07:00