Skip to content
  • Pavlo Strokov's avatar
    Introduction of in-memory cache for reads distribution · 1052c313
    Pavlo Strokov authored
    With enabled distributed_reads feature each read operation leads to
    a database query execution to get state of the storages for particular
    repository. More read calls leads to more database access operations,
    so the pressure to it increases in linear (or even worse).
    To mitigate this problem it was decided to introduce an in-memory cache
    added before accessing the database. Invalidation happens on receiving
    notification events from the database. The events are send by the
    triggers attached to the repositories (delete) and storage_repositories
    (insert, delete, update) tables.
    
    To monitor the cache a new counter was added: gitaly_praefect_uptodate_storages_cache_access_total.
    It tracks amount of cache hits, misses and populates and evicts per virtual
    repository. And to track an error rate of the notifications processing the
    gitaly_praefect_uptodate_storages_errors_total was added with type set to one of:
    retrieve, notification_decode.
    
    Closes: https://gitlab.com/gitlab-org/gitaly/-/issues/3053
    1052c313