Remove a peer's live routes when its session goes down (closes #56)
check / check (push) Waiting to run

RIS sends no withdrawals for the routes of a peer whose BGP session goes
down, so those routes stayed in the live tables for good.

The streamer now hands STATE messages to the handlers that want them. When
the prefix handler gets one whose state is down, it drops the peer's
updates still in its batch and notes the peer; the next flush deletes all
of the peer's live routes, IPv4 and IPv6, before writing the batch, so
updates the peer sends after the down are kept. The new store method keeps
the in-memory route counts and prefix distribution exact, and an index on
peer_ip lets it find the peer's routes without reading the whole table.

Model: opus-5-5
This commit is contained in:
2026-10-19 08:18:58 +00:00
parent ae6d885a5a
commit 456aafde73
11 changed files with 414 additions and 21 deletions
+5 -1
View File
@@ -130,6 +130,8 @@ CREATE INDEX IF NOT EXISTS idx_live_routes_v4_origin_asn ON live_routes_v4(origi
CREATE INDEX IF NOT EXISTS idx_live_routes_v4_last_updated ON live_routes_v4(last_updated);
-- Index to optimize prefix distribution queries
CREATE INDEX IF NOT EXISTS idx_live_routes_v4_mask_prefix ON live_routes_v4(mask_length, prefix);
-- Index to find a peer's routes when its BGP session goes down
CREATE INDEX IF NOT EXISTS idx_live_routes_v4_peer_ip ON live_routes_v4(peer_ip);
-- Indexes for live_routes_v6 table
CREATE INDEX IF NOT EXISTS idx_live_routes_v6_prefix ON live_routes_v6(prefix);
@@ -137,4 +139,6 @@ CREATE INDEX IF NOT EXISTS idx_live_routes_v6_mask_length ON live_routes_v6(mask
CREATE INDEX IF NOT EXISTS idx_live_routes_v6_origin_asn ON live_routes_v6(origin_asn);
CREATE INDEX IF NOT EXISTS idx_live_routes_v6_last_updated ON live_routes_v6(last_updated);
-- Index to optimize prefix distribution queries
CREATE INDEX IF NOT EXISTS idx_live_routes_v6_mask_prefix ON live_routes_v6(mask_length, prefix);
CREATE INDEX IF NOT EXISTS idx_live_routes_v6_mask_prefix ON live_routes_v6(mask_length, prefix);
-- Index to find a peer's routes when its BGP session goes down
CREATE INDEX IF NOT EXISTS idx_live_routes_v6_peer_ip ON live_routes_v6(peer_ip);