fix(chainwatch): Stop SyncIncomingBlocks from leaking into processing

The SQL query was anchoring data from the `blocks` table, which includes
all blocks seen from SyncIncomingBlocks which isn't always available in
the chainstate via the API. In order to prevent these blocks from
leaking into normal processing (which errors anyway), the join was
changed to allow `blocks_synced` to anchor the set as we originally
intended.
This commit is contained in:
Mike Greenberg 2020-09-03 12:45:17 -04:00
parent ddc5e57d4d
commit abaef98fd8

View File

@ -334,10 +334,10 @@ func (p *Processor) unprocessedBlocks(ctx context.Context, batch int) (map[cid.C
}() }()
rows, err := p.db.Query(` rows, err := p.db.Query(`
with toProcess as ( with toProcess as (
select blocks.cid, blocks.height, rank() over (order by height) as rnk select b.cid, b.height, rank() over (order by height) as rnk
from blocks from blocks_synced bs
left join blocks_synced bs on blocks.cid = bs.cid left join blocks b on bs.cid = b.cid
where bs.processed_at is null and blocks.height > 0 where bs.processed_at is null and b.height > 0
) )
select cid select cid
from toProcess from toProcess