Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
377862fb
Commit
377862fb
authored
Feb 27, 2020
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using uncached SQL queries for long running workers
parent
00d4d5be
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
6 deletions
+54
-6
changelogs/unreleased/207808-geo-bug-filedownloaddispatchworker-may-sometimes-excessively-resyn.yml
...ownloaddispatchworker-may-sometimes-excessively-resyn.yml
+5
-0
ee/app/workers/geo/scheduler/scheduler_worker.rb
ee/app/workers/geo/scheduler/scheduler_worker.rb
+1
-1
ee/lib/ee/gitlab/database.rb
ee/lib/ee/gitlab/database.rb
+10
-0
ee/spec/support/caching.rb
ee/spec/support/caching.rb
+9
-0
ee/spec/workers/geo/container_repository_sync_dispatch_worker_spec.rb
...ers/geo/container_repository_sync_dispatch_worker_spec.rb
+1
-1
ee/spec/workers/geo/file_download_dispatch_worker_spec.rb
ee/spec/workers/geo/file_download_dispatch_worker_spec.rb
+25
-1
ee/spec/workers/geo/migrated_local_files_clean_up_worker_spec.rb
.../workers/geo/migrated_local_files_clean_up_worker_spec.rb
+1
-1
ee/spec/workers/geo/repository_shard_sync_worker_spec.rb
ee/spec/workers/geo/repository_shard_sync_worker_spec.rb
+1
-1
ee/spec/workers/geo/repository_verification/secondary/shard_worker_spec.rb
...eo/repository_verification/secondary/shard_worker_spec.rb
+1
-1
No files found.
changelogs/unreleased/207808-geo-bug-filedownloaddispatchworker-may-sometimes-excessively-resyn.yml
0 → 100644
View file @
377862fb
---
title
:
'
Use
uncached
SQL
queries
for
Geo
long-running
workers'
merge_request
:
26187
author
:
type
:
fixed
ee/app/workers/geo/scheduler/scheduler_worker.rb
View file @
377862fb
...
...
@@ -170,7 +170,7 @@ module Geo
def
update_pending_resources
if
reload_queue?
@pending_resources
=
load_pending_resources
@pending_resources
=
Gitlab
::
Database
.
geo_uncached_queries
{
load_pending_resources
}
set_backoff_time!
if
should_apply_backoff?
end
end
...
...
ee/lib/ee/gitlab/database.rb
View file @
377862fb
...
...
@@ -24,6 +24,16 @@ module EE
ActiveRecord
::
Base
.
establish_connection
(
config
)
end
def
geo_uncached_queries
raise
'No block given'
unless
block_given?
Geo
::
TrackingBase
.
uncached
do
ActiveRecord
::
Base
.
uncached
do
yield
end
end
end
end
end
end
...
...
ee/spec/support/caching.rb
0 → 100644
View file @
377862fb
# frozen_string_literal: true
RSpec
.
configure
do
|
config
|
config
.
around
(
:each
,
:use_sql_query_cache_for_tracking_db
)
do
|
example
|
Geo
::
TrackingBase
.
cache
do
example
.
run
end
end
end
ee/spec/workers/geo/container_repository_sync_dispatch_worker_spec.rb
View file @
377862fb
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
Geo
::
ContainerRepositorySyncDispatchWorker
,
:geo
,
:geo_fdw
do
describe
Geo
::
ContainerRepositorySyncDispatchWorker
,
:geo
,
:geo_fdw
,
:use_sql_query_cache_for_tracking_db
do
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
...
...
ee/spec/workers/geo/file_download_dispatch_worker_spec.rb
View file @
377862fb
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
Geo
::
FileDownloadDispatchWorker
,
:geo
,
:geo_fdw
do
describe
Geo
::
FileDownloadDispatchWorker
,
:geo
,
:geo_fdw
,
:use_sql_query_cache_for_tracking_db
do
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
...
...
@@ -59,6 +59,30 @@ describe Geo::FileDownloadDispatchWorker, :geo, :geo_fdw do
subject
.
perform
end
it
'does not schedule duplicated jobs because of query cache'
do
lfs_object_1
=
create
(
:lfs_object
,
:with_file
)
lfs_object_2
=
create
(
:lfs_object
,
:with_file
)
lfs_object_3
=
create
(
:lfs_object
,
:with_file
)
create
(
:geo_lfs_object_registry
,
:never_synced
,
lfs_object:
lfs_object_1
)
create
(
:geo_lfs_object_registry
,
:never_synced
,
lfs_object:
lfs_object_2
)
create
(
:geo_lfs_object_registry
,
:never_synced
,
lfs_object:
lfs_object_3
)
stub_const
(
'Geo::Scheduler::SchedulerWorker::DB_RETRIEVE_BATCH_SIZE'
,
3
)
secondary
.
update!
(
files_max_capacity:
3
)
expect
(
Geo
::
FileDownloadWorker
).
to
receive
(
:perform_async
).
with
(
'lfs'
,
lfs_object_1
.
id
).
once
do
Thread
.
new
do
# Rails will invalidate the query cache if the update happens in the same thread
Geo
::
LfsObjectRegistry
.
update
(
success:
true
)
end
end
expect
(
Geo
::
FileDownloadWorker
).
to
receive
(
:perform_async
).
with
(
'lfs'
,
lfs_object_2
.
id
).
once
expect
(
Geo
::
FileDownloadWorker
).
to
receive
(
:perform_async
).
with
(
'lfs'
,
lfs_object_3
.
id
).
once
subject
.
perform
end
context
'with attachments (Upload records)'
do
let
(
:upload
)
{
create
(
:upload
)
}
...
...
ee/spec/workers/geo/migrated_local_files_clean_up_worker_spec.rb
View file @
377862fb
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
Geo
::
MigratedLocalFilesCleanUpWorker
,
:geo
,
:geo_fdw
do
describe
Geo
::
MigratedLocalFilesCleanUpWorker
,
:geo
,
:geo_fdw
,
:use_sql_query_cache_for_tracking_db
do
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
...
...
ee/spec/workers/geo/repository_shard_sync_worker_spec.rb
View file @
377862fb
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
Geo
::
RepositoryShardSyncWorker
,
:geo
,
:geo_fdw
,
:clean_gitlab_redis_cache
do
describe
Geo
::
RepositoryShardSyncWorker
,
:geo
,
:geo_fdw
,
:clean_gitlab_redis_cache
,
:use_sql_query_cache_for_tracking_db
do
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
...
...
ee/spec/workers/geo/repository_verification/secondary/shard_worker_spec.rb
View file @
377862fb
...
...
@@ -2,7 +2,7 @@
require
'spec_helper'
describe
Geo
::
RepositoryVerification
::
Secondary
::
ShardWorker
,
:geo
,
:geo_fdw
,
:request_store
,
:clean_gitlab_redis_cache
do
describe
Geo
::
RepositoryVerification
::
Secondary
::
ShardWorker
,
:geo
,
:geo_fdw
,
:request_store
,
:clean_gitlab_redis_cache
,
:use_sql_query_cache_for_tracking_db
do
include
::
EE
::
GeoHelpers
include
ExclusiveLeaseHelpers
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment