deso-protocol / deso-protocol/postgres-data-handler

Missing blocks

Offen
#106 4 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
2
Forks
5
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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;

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.