diff --git a/storage/mysql/mysql.go b/storage/mysql/mysql.go index a3aebe4a..e2ece398 100644 --- a/storage/mysql/mysql.go +++ b/storage/mysql/mysql.go @@ -261,14 +261,17 @@ func (s *Storage) ReadTile(ctx context.Context, level, index, minTreeSize uint64 // Do some validation to make sure we don't return data at a tree size we haven't reached yet // Doing so could break caching at a higher level - entriesPerLevel := 1 << level * 8 + startOfTileSize := (1 << ((1 + level) * 8)) * index // Size of perfect tree if this tile had 0 entries in it + klog.Warningf("startOfTileSize (level %d, index %d) %d", level, index, startOfTileSize) + numEntries := uint64(len(tile) / 32) + entriesPerPerfectSubtree := uint64(1 << (level * 8)) // Each leaf at this level implies this many permanent entries in the tree - minPermanentEntries := numEntries * uint64(entriesPerLevel) + minPermanentEntries := startOfTileSize + numEntries*uint64(entriesPerPerfectSubtree) if minTreeSize > minPermanentEntries { // If the user has requested a size larger than we have, they can't have it - return nil, os.ErrNotExist + return nil, fmt.Errorf("Requested tree size %d but tree size is %d: %w", minTreeSize, minPermanentEntries, os.ErrNotExist) } return tile, nil