fix(shadow): repair UTC sampling and persist v3 diagnostics

This commit is contained in:
zgw
2026-09-07 10:12:41 +08:00
parent 5ce6393337
commit 79e0db29f9
15 changed files with 678 additions and 34 deletions

View File

@@ -1,6 +1,7 @@
:on error exit
:out "$(OutputDir)\sql-diagnostics.txt"
-- Run via shadow-v3-export.cmd: literal output names are relative to its OUTPUT_DIR.
:out "sql-diagnostics.txt"
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
@@ -73,7 +74,7 @@ WHERE request.database_id = DB_ID()
ORDER BY request.session_id;
GO
:out "$(OutputDir)\comparison-detail.txt"
:out "comparison-detail.txt"
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
@@ -108,19 +109,23 @@ WHERE warehouse_id = '$(WarehouseId)'
AND created_at >= CONVERT(datetime2(3), '$(StartUtc)', 127)
ORDER BY created_at, decision_id;
SELECT SUM(CASE WHEN decision_type = 'INBOUND' THEN 1 ELSE 0 END) AS inbound_plan_count,
SUM(CASE WHEN decision_type = 'INBOUND_COMPARE' THEN 1 ELSE 0 END) AS inbound_compare_count,
SUM(CASE WHEN decision_type = 'OUTBOUND' THEN 1 ELSE 0 END) AS outbound_plan_count,
SUM(CASE WHEN decision_type = 'OUTBOUND_COMPARE' THEN 1 ELSE 0 END) AS outbound_compare_count
SELECT COUNT_BIG(CASE WHEN decision_type = 'INBOUND' THEN 1 END) AS inbound_plan_count,
COUNT_BIG(CASE WHEN decision_type = 'INBOUND_COMPARE' THEN 1 END) AS inbound_compare_count,
COUNT_BIG(CASE WHEN decision_type = 'OUTBOUND' THEN 1 END) AS outbound_plan_count,
COUNT_BIG(CASE WHEN decision_type = 'OUTBOUND_COMPARE' THEN 1 END) AS outbound_compare_count,
CASE WHEN COUNT_BIG(CASE WHEN decision_type IN ('INBOUND_COMPARE', 'OUTBOUND_COMPARE') THEN 1 END) = 0
THEN 'NO_COMPARISONS' ELSE 'COMPARISONS_PRESENT_NOT_APPROVED' END AS sample_status
FROM alg.decision_log
WHERE warehouse_id = '$(WarehouseId)'
AND created_at >= CONVERT(datetime2(3), '$(StartUtc)', 127);
GO
:out "$(OutputDir)\runtime-metrics.txt"
:out "runtime-metrics.txt"
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
SELECT 'Counters are cumulative, not filtered by StartUtc; pre-V3.2 flushed_at may use JVM local time until next flush.' AS metric_scope;
SELECT warehouse_id, metric_name, bucket_upper_micros, metric_count,
metric_total_micros, metric_max_micros, flushed_at
FROM alg.shadow_runtime_metric
@@ -146,7 +151,7 @@ GROUP BY CASE
ORDER BY metric_group;
GO
:out "$(OutputDir)\inventory-parity.txt"
:out "inventory-parity.txt"
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;