Skip to content

Let IReminderTable to see all hash ranges at once #9381

@DunetsNM

Description

@DunetsNM

I have a custom implementation of IReminderTable which reads reminders from SQL database (ticks get persisted by other means which is not relevant here). By default there's 30 hash range buckets in each silo, so when Reminder Service refreshes it invokes 30 ReadRows in parallel resulting in 30 parallel SQL queries. While each query is lightweight it'd be even faster if I could make it all in one db roundtrip.

Currently the only idea I have is to make ReadRows(int, int) load all reminders for all silos and cache them for short time (like a minute - anything lower than refresh interval), or get them from the cache and then filter only reminders for the specified hash range. While it reduces number of db roundtrips the tradeoff is it'll fetch and filter more data than required (there's multiple silos).

So, how can I access all the hash ranges inside my Reminder Table implementation, to fetch only relevant reminders but for all buckets at once? Is it possible with current IReminderTable interface at all?

If not possible, then how about changing signature of Task<ReminderTableData> ReadRows(uint begin, uint end) to something like this (could be more readable but it communicates the idea)

Task<ReminderTableData>[] StartReadRowsForRanges((uint begin, uint end)[] ranges);

ReadRows is called for all hash ranges at once anyway via private LocalReminderService.ReadTableAndStartTimers methods, which are then awaited together via Task.WhenAll. This is easy to replace with a call to StartReadRowsForRanges which would return array of hot task each then passed to ReadTableAndStartTimers, and it'd be up to IReminderTable implemenation to decide what to do: run each bucket as a separate query, or merge it all into one query and then fill TaskCompletionSources. Do I miss anything here?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions