fix(crawler): realtime_table id bigint(시퀀스 오버플로) + HCX 폴링 비활성 #8
@@ -53,7 +53,7 @@
|
||||
"grpcPort": 50055,
|
||||
"pollIntervalMs": 1000,
|
||||
"registerMapPath": "",
|
||||
"enabled": true
|
||||
"enabled": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -705,7 +705,7 @@ public class Hc900DbService : IExperionDbService
|
||||
// realtime_table 생성 (실시간 모니터링 포인트)
|
||||
await _ctx.Database.ExecuteSqlRawAsync("""
|
||||
CREATE TABLE IF NOT EXISTS realtime_table (
|
||||
id SERIAL PRIMARY KEY,
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
tagname TEXT NOT NULL,
|
||||
node_id TEXT NOT NULL,
|
||||
livevalue TEXT,
|
||||
@@ -772,6 +772,21 @@ public class Hc900DbService : IExperionDbService
|
||||
ON event_history_table(tagname, event_type, event_time DESC);
|
||||
""");
|
||||
|
||||
// ── realtime_table.id int4→bigint 마이그레이션 (멱등) ───────────────
|
||||
// realtime_table은 upsert지만 매 poll마다 nextval을 소비 → SERIAL(int4)은
|
||||
// 2^31에서 오버플로해 전체 업서트가 멈춘다(운영 사고). 이미 bigint면 no-op.
|
||||
await _ctx.Database.ExecuteSqlRawAsync("""
|
||||
DO $$
|
||||
BEGIN
|
||||
IF (SELECT data_type FROM information_schema.columns
|
||||
WHERE table_schema = current_schema()
|
||||
AND table_name = 'realtime_table' AND column_name = 'id') = 'integer' THEN
|
||||
ALTER TABLE realtime_table ALTER COLUMN id TYPE bigint;
|
||||
ALTER SEQUENCE realtime_table_id_seq AS bigint MAXVALUE 9223372036854775807;
|
||||
END IF;
|
||||
END $$;
|
||||
""");
|
||||
|
||||
// ── Multi-Controller Migration (controller_id) ─────────────────────
|
||||
// 기존 테이블에 controller_id 컬럼 추가 (멱등)
|
||||
await _ctx.Database.ExecuteSqlRawAsync(
|
||||
|
||||
Reference in New Issue
Block a user