Summary
Redesign query-job timestamp handling so MariaDB is the single source of truth for query start and termination times.
Required changes
- Set the query-job start time when the query starts, using the MariaDB server time.
- Set an end time when the query reaches a terminal state.
- Ensure every terminated query has an end time, including failed, killed, and cancelled queries.
- Derive duration from
end_time - start_time when duration is required.
- Update affected query scheduler and orchestration database schema code.
Rationale
The current scheduler sets start_time and calculates duration from scheduler-host time. A terminated job can also have no duration when no start time was set. Database-generated timestamps avoid host-clock differences and provide a reliable termination time for result-retention cleanup.
Affected areas
- Query scheduler timestamp updates.
- Orchestration database query-jobs schema and migrations.
- Consumers of
start_time and duration, including search-result garbage collection.
Acceptance criteria
- MariaDB generates query start and end timestamps.
- Every terminal query state records an end time.
- Duration, where needed, is derived from the stored start and end times.
- Result-retention logic can determine expiry for all terminal query jobs.
Backlinks
Requested by @LinZhihao-723.
Summary
Redesign query-job timestamp handling so MariaDB is the single source of truth for query start and termination times.
Required changes
end_time - start_timewhen duration is required.Rationale
The current scheduler sets
start_timeand calculatesdurationfrom scheduler-host time. A terminated job can also have no duration when no start time was set. Database-generated timestamps avoid host-clock differences and provide a reliable termination time for result-retention cleanup.Affected areas
start_timeandduration, including search-result garbage collection.Acceptance criteria
Backlinks
Requested by @LinZhihao-723.