deso-protocol / deso-protocol/postgres-data-handler
Missing blocks
- Ngôn ngữ chính
- Go
- Star
- 2
- Fork
- 5
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
We have several GraphQL data-handlers on several nodes (SafetyNet, BeyondSocial) and found in the PostgreSQL DB missing blocks (gaps) occur.
Also have seen regardless of the message Starting sync from beginning that first 17 Million blocks were skipped (not sure if the state-changes or consumer process are dropping or what causes this)
Sharing here a query to identify those gaps, but also a feature request: how to repair those gaps a flag for the data-handler to repair-gaps?
WITH missing_blocks AS (
SELECT ah.height
FROM (
SELECT generate_series(
(SELECT MIN(height) FROM block),
(SELECT MAX(height) FROM block)
) AS height
) AS ah
LEFT JOIN block b ON b.height = ah.height
WHERE b.height IS NULL
),
grouped AS (
SELECT
height,
SUM(is_new_group) OVER (ORDER BY height) AS group_id
FROM (
SELECT
height,
CASE
WHEN height - LAG(height) OVER (ORDER BY height) >= 10 THEN 1
ELSE 0
END AS is_new_group
FROM missing_blocks
) AS t
)
SELECT
MIN(height) AS start_height,
MAX(height) AS end_height,
COUNT(*) AS missing_count
FROM grouped
GROUP BY group_id
ORDER BY start_height;
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.