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-15 01:28:53 +0300
committerPavlo Strokov <pstrokov@gitlab.com>2020-12-17 20:37:34 +0300
commit71c447afcd16078eef5553ba1633383863c982d5 (patch)
tree4c4d3b127257885815d2f763d4295e29e39ab4eb /internal/praefect/datastore
parent7af9c950110a86775621b3db2af8e23056c0cb4c (diff)
Removal of IsLatestGeneration
IsLatestGeneration method has no usages anymore as the primary now verified with the result of the GetConsistentStorages call. Part of: https://gitlab.com/gitlab-org/gitaly/-/issues/3337
Diffstat (limited to 'internal/praefect/datastore')
-rw-r--r--internal/praefect/datastore/repository_store.go30
-rw-r--r--internal/praefect/datastore/repository_store_mock.go9
-rw-r--r--internal/praefect/datastore/repository_store_test.go23
3 files changed, 0 insertions, 62 deletions
diff --git a/internal/praefect/datastore/repository_store.go b/internal/praefect/datastore/repository_store.go
index bdcc7a198..6c9b081f0 100644
--- a/internal/praefect/datastore/repository_store.go
+++ b/internal/praefect/datastore/repository_store.go
@@ -86,9 +86,6 @@ type RepositoryStore interface {
RenameRepository(ctx context.Context, virtualStorage, relativePath, storage, newRelativePath string) error
// GetConsistentStorages checks which storages are on the latest generation and returns them.
GetConsistentStorages(ctx context.Context, virtualStorage, relativePath string) (map[string]struct{}, error)
- // IsLatestGeneration checks whether the repository is on the latest generation or not. If the repository does not
- // have an expected generation, every storage is considered to be on the latest version.
- IsLatestGeneration(ctx context.Context, virtualStorage, relativePath, storage string) (bool, error)
// RepositoryExists returns whether the repository exists on a virtual storage.
RepositoryExists(ctx context.Context, virtualStorage, relativePath string) (bool, error)
// GetPartiallyReplicatedRepositories returns information on repositories which have an outdated copy on an assigned storage.
@@ -385,33 +382,6 @@ JOIN expected_repositories USING (virtual_storage, relative_path, generation)
return consistentSecondaries, nil
}
-func (rs *PostgresRepositoryStore) IsLatestGeneration(ctx context.Context, virtualStorage, relativePath, storage string) (bool, error) {
- const q = `
-SELECT COALESCE(expected_repository.generation = storage_repositories.generation, false)
-FROM (
- SELECT virtual_storage, relative_path, $3 AS storage, MAX(generation) AS generation
- FROM storage_repositories
- WHERE virtual_storage = $1
- AND relative_path = $2
- GROUP BY virtual_storage, relative_path
-) AS expected_repository
-LEFT JOIN storage_repositories USING (virtual_storage, relative_path, storage)
-`
-
- var isLatest bool
- if err := rs.db.QueryRowContext(ctx, q, virtualStorage, relativePath, storage).Scan(&isLatest); err != nil {
- if errors.Is(err, sql.ErrNoRows) {
- // if there is no record of the expected generation, we'll have to consider the storage
- // up to date as this will be the case on repository creation
- return true, nil
- }
-
- return false, err
- }
-
- return isLatest, nil
-}
-
func (rs *PostgresRepositoryStore) RepositoryExists(ctx context.Context, virtualStorage, relativePath string) (bool, error) {
const q = `
SELECT true
diff --git a/internal/praefect/datastore/repository_store_mock.go b/internal/praefect/datastore/repository_store_mock.go
index 2b943fdaf..133bcf744 100644
--- a/internal/praefect/datastore/repository_store_mock.go
+++ b/internal/praefect/datastore/repository_store_mock.go
@@ -7,7 +7,6 @@ import "context"
type MockRepositoryStore struct {
GetGenerationFunc func(ctx context.Context, virtualStorage, relativePath, storage string) (int, error)
IncrementGenerationFunc func(ctx context.Context, virtualStorage, relativePath, primary string, secondaries []string) error
- IsLatestGenerationFunc func(ctx context.Context, virtualStorage, relativePath, storage string) (bool, error)
GetReplicatedGenerationFunc func(ctx context.Context, virtualStorage, relativePath, source, target string) (int, error)
SetGenerationFunc func(ctx context.Context, virtualStorage, relativePath, storage string, generation int) error
DeleteRepositoryFunc func(ctx context.Context, virtualStorage, relativePath, storage string) error
@@ -34,14 +33,6 @@ func (m MockRepositoryStore) IncrementGeneration(ctx context.Context, virtualSto
return m.IncrementGenerationFunc(ctx, virtualStorage, relativePath, primary, secondaries)
}
-func (m MockRepositoryStore) IsLatestGeneration(ctx context.Context, virtualStorage, relativePath, storage string) (bool, error) {
- if m.IsLatestGenerationFunc == nil {
- return true, nil
- }
-
- return m.IsLatestGenerationFunc(ctx, virtualStorage, relativePath, storage)
-}
-
func (m MockRepositoryStore) GetReplicatedGeneration(ctx context.Context, virtualStorage, relativePath, source, target string) (int, error) {
if m.GetReplicatedGenerationFunc == nil {
return GenerationUnknown, nil
diff --git a/internal/praefect/datastore/repository_store_test.go b/internal/praefect/datastore/repository_store_test.go
index 33ba4fbb0..69ae09653 100644
--- a/internal/praefect/datastore/repository_store_test.go
+++ b/internal/praefect/datastore/repository_store_test.go
@@ -534,29 +534,6 @@ func testRepositoryStore(t *testing.T, newStore repositoryStoreFactory) {
})
})
- t.Run("IsLatestGeneration", func(t *testing.T) {
- rs, _ := newStore(t, nil)
-
- latest, err := rs.IsLatestGeneration(ctx, vs, repo, "no-expected-record")
- require.NoError(t, err)
- require.True(t, latest)
-
- require.NoError(t, rs.SetGeneration(ctx, vs, repo, "up-to-date", 1))
- require.NoError(t, rs.SetGeneration(ctx, vs, repo, "outdated", 0))
-
- latest, err = rs.IsLatestGeneration(ctx, vs, repo, "no-record")
- require.NoError(t, err)
- require.False(t, latest)
-
- latest, err = rs.IsLatestGeneration(ctx, vs, repo, "outdated")
- require.NoError(t, err)
- require.False(t, latest)
-
- latest, err = rs.IsLatestGeneration(ctx, vs, repo, "up-to-date")
- require.NoError(t, err)
- require.True(t, latest)
- })
-
t.Run("RepositoryExists", func(t *testing.T) {
rs, _ := newStore(t, nil)