Skip to content

SQL Server LastBlockProcessed is set to NVARCHAR #19

@jpmyburghbc

Description

@jpmyburghbc

The following method does a MaxAsync on the BlockProgress table but the LastBlockProcessed column is set to NVARCHAR in the SQL scripts supplied, as a result, the query will return a value to the nearest 9, 99, 999 etc and not the actual last block processed, this can cause the processor to re-process a large number of blocks when restarted.

public async Task<BigInteger?> GetLastBlockNumberProcessedAsync()

public async Task<BigInteger?> GetLastBlockNumberProcessedAsync() { using (var context = _contextFactory.CreateContext()) { var max = await context.BlockProgress.MaxAsync(b => b.LastBlockProcessed).ConfigureAwait(false); return string.IsNullOrEmpty(max) ? (BigInteger?)null : BigInteger.Parse(max); } }

Steps to recreate

  1.    Add 19999 blocks in the `BlockProgress` table
    
  2.    Now run `SELECT Max([LastBlockProcessed]) FROM [BlockProgress]`
    
  3.    Result returned 9999 as LastBlockProcessed resulting in 10k blocks needing to be reprocessed
    
  4.    Expected query to return 19999 as LastBlockProcessed
    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions