Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlo Strokov <pstrokov@gitlab.com>2020-12-10 16:52:45 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-12-10 16:52:45 +0300
commit09c6d25de370446ac855a8241d8f821ed3f1ceec (patch)
tree6de991c7dc079208fbbd953f2c27865255192a1d /internal/praefect/server_factory_test.go
parent873c388ed3c1c458c34f349e31d122dbe3813bc2 (diff)
On each read/write operation praefect requires to know which
gitaly node is a primary. For mutator operations it used to define from what node the response will be returned back to the client. For the read operations it is used to redirect request to or as a fallback option for reads distribution in case it is enabled. The default strategy for defining the primary is an 'sql' which means the primary is tracked inside Postgres database and praefect issues select statement into it each time it needs to define current primary. It creates a high load on the database when there are too many read operations (the outcome of the performance testing). To resolve this problem we change logic of retrieving set of up to date storages to return all storages including primary. So now we don't need to know the current primary and use any storage that has latest generation of the repository to serve the requests. As this information is cached by the in-memory cache praefect won't create a high load on the database anymore. This change also makes check IsLatestGeneration for the primary node redundant as it won't be present in the set of consistent storages if its generation not the latest one. Closes: https://gitlab.com/gitlab-org/gitaly/-/issues/3337
Diffstat (limited to 'internal/praefect/server_factory_test.go')
-rw-r--r--internal/praefect/server_factory_test.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/praefect/server_factory_test.go b/internal/praefect/server_factory_test.go
index d1601a566..c87d69140 100644
--- a/internal/praefect/server_factory_test.go
+++ b/internal/praefect/server_factory_test.go
@@ -80,7 +80,11 @@ func TestServerFactory(t *testing.T) {
logger := testhelper.DiscardTestEntry(t)
queue := datastore.NewMemoryReplicationEventQueue(conf)
- rs := datastore.MockRepositoryStore{}
+ rs := datastore.MockRepositoryStore{
+ GetConsistentStoragesFunc: func(context.Context, string, string) (map[string]struct{}, error) {
+ return map[string]struct{}{conf.VirtualStorages[0].Nodes[0].Storage: {}}, nil
+ },
+ }
sp := datastore.NewDirectStorageProvider(rs)
nodeMgr, err := nodes.NewManager(logger, conf, nil, rs, sp, &promtest.MockHistogramVec{}, protoregistry.GitalyProtoPreregistered, nil)
require.NoError(t, err)