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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
67d310a1
Commit
67d310a1
authored
Feb 08, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix orphan temp table untracked_files_for_uploads
parent
f917fc5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
26 deletions
+27
-26
lib/gitlab/background_migration/prepare_untracked_uploads.rb
lib/gitlab/background_migration/prepare_untracked_uploads.rb
+10
-1
spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
...ab/background_migration/prepare_untracked_uploads_spec.rb
+17
-25
No files found.
lib/gitlab/background_migration/prepare_untracked_uploads.rb
View file @
67d310a1
...
@@ -43,7 +43,11 @@ module Gitlab
...
@@ -43,7 +43,11 @@ module Gitlab
store_untracked_file_paths
store_untracked_file_paths
schedule_populate_untracked_uploads_jobs
if
UntrackedFile
.
all
.
empty?
drop_temp_table
else
schedule_populate_untracked_uploads_jobs
end
end
end
private
private
...
@@ -165,6 +169,11 @@ module Gitlab
...
@@ -165,6 +169,11 @@ module Gitlab
bulk_queue_background_migration_jobs_by_range
(
bulk_queue_background_migration_jobs_by_range
(
UntrackedFile
,
FOLLOW_UP_MIGRATION
)
UntrackedFile
,
FOLLOW_UP_MIGRATION
)
end
end
def
drop_temp_table
UntrackedFile
.
connection
.
drop_table
(
:untracked_files_for_uploads
,
if_exists:
true
)
end
end
end
end
end
end
end
spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
View file @
67d310a1
...
@@ -8,8 +8,6 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
...
@@ -8,8 +8,6 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
before
do
before
do
DatabaseCleaner
.
clean
DatabaseCleaner
.
clean
drop_temp_table_if_exists
end
end
after
do
after
do
...
@@ -44,27 +42,6 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
...
@@ -44,27 +42,6 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
end
end
end
end
it
'ensures the untracked_files_for_uploads table exists'
do
expect
do
described_class
.
new
.
perform
end
.
to
change
{
ActiveRecord
::
Base
.
connection
.
table_exists?
(
:untracked_files_for_uploads
)
}.
from
(
false
).
to
(
true
)
end
it
'has a path field long enough for really long paths'
do
described_class
.
new
.
perform
component
=
'a'
*
255
long_path
=
[
'uploads'
,
component
,
# project.full_path
component
# filename
].
flatten
.
join
(
'/'
)
record
=
untracked_files_for_uploads
.
create!
(
path:
long_path
)
expect
(
record
.
reload
.
path
.
size
).
to
eq
(
519
)
end
context
"test bulk insert with ON CONFLICT DO NOTHING or IGNORE"
do
context
"test bulk insert with ON CONFLICT DO NOTHING or IGNORE"
do
around
do
|
example
|
around
do
|
example
|
# If this is CI, we use Postgres 9.2 so this whole context should be
# If this is CI, we use Postgres 9.2 so this whole context should be
...
@@ -90,6 +67,21 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
...
@@ -90,6 +67,21 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
UploadService
.
new
(
project2
,
uploaded_file
,
FileUploader
).
execute
UploadService
.
new
(
project2
,
uploaded_file
,
FileUploader
).
execute
end
end
it
'has a path field long enough for really long paths'
do
described_class
.
new
.
perform
component
=
'a'
*
255
long_path
=
[
'uploads'
,
component
,
# project.full_path
component
# filename
].
flatten
.
join
(
'/'
)
record
=
untracked_files_for_uploads
.
create!
(
path:
long_path
)
expect
(
record
.
reload
.
path
.
size
).
to
eq
(
519
)
end
it
'adds unhashed files to the untracked_files_for_uploads table'
do
it
'adds unhashed files to the untracked_files_for_uploads table'
do
described_class
.
new
.
perform
described_class
.
new
.
perform
...
@@ -235,10 +227,10 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
...
@@ -235,10 +227,10 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq do
# Very new or lightly-used installations that are running this migration
# Very new or lightly-used installations that are running this migration
# may not have an upload directory because they have no uploads.
# may not have an upload directory because they have no uploads.
context
'when no files were ever uploaded'
do
context
'when no files were ever uploaded'
do
it
'd
oes not add to the untracked_files_for_uploads
table (and does not raise error)'
do
it
'd
eletes the `untracked_files_for_uploads`
table (and does not raise error)'
do
described_class
.
new
.
perform
described_class
.
new
.
perform
expect
(
untracked_files_for_uploads
.
co
unt
).
to
eq
(
0
)
expect
(
untracked_files_for_uploads
.
co
nnection
.
table_exists?
(
:untracked_files_for_uploads
)).
to
be_falsey
end
end
end
end
end
end
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