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
44d93595
Commit
44d93595
authored
Jul 11, 2019
by
Nick Thomas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE: Remove dead MySQL code
parent
ef1efa0f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
67 deletions
+24
-67
ee/app/models/ee/epic.rb
ee/app/models/ee/epic.rb
+1
-7
ee/app/workers/clear_shared_runners_minutes_worker.rb
ee/app/workers/clear_shared_runners_minutes_worker.rb
+5
-8
ee/lib/ee/gitlab/background_migration/rollback_import_state_data.rb
...gitlab/background_migration/rollback_import_state_data.rb
+12
-26
ee/lib/ee/gitlab/database.rb
ee/lib/ee/gitlab/database.rb
+0
-2
ee/lib/gitlab/geo.rb
ee/lib/gitlab/geo.rb
+1
-1
ee/spec/lib/ee/gitlab/database_spec.rb
ee/spec/lib/ee/gitlab/database_spec.rb
+5
-17
ee/spec/lib/gitlab/geo_spec.rb
ee/spec/lib/gitlab/geo_spec.rb
+0
-6
No files found.
ee/app/models/ee/epic.rb
View file @
44d93595
...
...
@@ -52,10 +52,7 @@ module EE
scope
:inc_group
,
->
{
includes
(
:group
)
}
scope
:order_start_or_end_date_asc
,
->
do
# mysql returns null values first in opposite to postgres which
# returns them last by default
nulls_first
=
::
Gitlab
::
Database
.
postgresql?
?
'NULLS FIRST'
:
''
reorder
(
"COALESCE(start_date, end_date) ASC
#{
nulls_first
}
"
)
reorder
(
"COALESCE(start_date, end_date) ASC NULLS FIRST"
)
end
scope
:order_start_date_asc
,
->
do
...
...
@@ -170,9 +167,6 @@ module EE
end
def
update_start_and_due_dates
(
epics
)
# In MySQL, we cannot use a subquery that references the table being updated
epics
=
epics
.
pluck
(
:id
)
if
::
Gitlab
::
Database
.
mysql?
&&
epics
.
is_a?
(
ActiveRecord
::
Relation
)
self
.
where
(
id:
epics
).
update_all
(
[
%{
...
...
ee/app/workers/clear_shared_runners_minutes_worker.rb
View file @
44d93595
...
...
@@ -10,14 +10,11 @@ class ClearSharedRunnersMinutesWorker
def
perform
return
unless
try_obtain_lease
if
Gitlab
::
Database
.
postgresql?
# Using UPDATE with a joined table is not supported in MySql
Namespace
.
with_shared_runners_minutes_limit
.
with_extra_shared_runners_minutes_limit
.
where
(
'namespace_statistics.namespace_id = namespaces.id'
)
.
where
(
'namespace_statistics.shared_runners_seconds > (namespaces.shared_runners_minutes_limit * 60)'
)
.
update_all
(
"extra_shared_runners_minutes_limit =
#{
extra_minutes_left_sql
}
FROM namespace_statistics"
)
end
Namespace
.
with_shared_runners_minutes_limit
.
with_extra_shared_runners_minutes_limit
.
where
(
'namespace_statistics.namespace_id = namespaces.id'
)
.
where
(
'namespace_statistics.shared_runners_seconds > (namespaces.shared_runners_minutes_limit * 60)'
)
.
update_all
(
"extra_shared_runners_minutes_limit =
#{
extra_minutes_left_sql
}
FROM namespace_statistics"
)
Namespace
.
where
(
'last_ci_minutes_notification_at IS NOT NULL OR last_ci_minutes_usage_notification_level IS NOT NULL'
)
.
each_batch
do
|
relation
|
...
...
ee/lib/ee/gitlab/background_migration/rollback_import_state_data.rb
View file @
44d93595
...
...
@@ -10,32 +10,18 @@ module EE
def
move_attributes_data_to_project
(
start_id
,
end_id
)
Rails
.
logger
.
info
(
"
#{
self
.
class
.
name
}
- Moving import attributes data to projects table:
#{
start_id
}
-
#{
end_id
}
"
)
# rubocop:disable Gitlab/RailsLogger
if
::
Gitlab
::
Database
.
mysql?
ActiveRecord
::
Base
.
connection
.
execute
<<~
SQL
UPDATE projects, project_mirror_data
SET
projects.import_status = project_mirror_data.status,
projects.import_jid = project_mirror_data.jid,
projects.mirror_last_update_at = project_mirror_data.last_update_at,
projects.mirror_last_successful_update_at = project_mirror_data.last_successful_update_at,
projects.import_error = project_mirror_data.last_error
WHERE project_mirror_data.project_id = projects.id
AND project_mirror_data.id BETWEEN
#{
start_id
}
AND
#{
end_id
}
SQL
else
ActiveRecord
::
Base
.
connection
.
execute
<<~
SQL
UPDATE projects
SET
import_status = project_mirror_data.status,
import_jid = project_mirror_data.jid,
mirror_last_update_at = project_mirror_data.last_update_at,
mirror_last_successful_update_at = project_mirror_data.last_successful_update_at,
import_error = project_mirror_data.last_error
FROM project_mirror_data
WHERE project_mirror_data.project_id = projects.id
AND project_mirror_data.id BETWEEN
#{
start_id
}
AND
#{
end_id
}
SQL
end
ActiveRecord
::
Base
.
connection
.
execute
<<~
SQL
UPDATE projects
SET
import_status = project_mirror_data.status,
import_jid = project_mirror_data.jid,
mirror_last_update_at = project_mirror_data.last_update_at,
mirror_last_successful_update_at = project_mirror_data.last_successful_update_at,
import_error = project_mirror_data.last_error
FROM project_mirror_data
WHERE project_mirror_data.project_id = projects.id
AND project_mirror_data.id BETWEEN
#{
start_id
}
AND
#{
end_id
}
SQL
end
end
end
...
...
ee/lib/ee/gitlab/database.rb
View file @
44d93595
...
...
@@ -14,8 +14,6 @@ module EE
end
def
healthy?
return
true
unless
postgresql?
!
Postgresql
::
ReplicationSlot
.
lag_too_great?
end
...
...
ee/lib/gitlab/geo.rb
View file @
44d93595
...
...
@@ -29,7 +29,7 @@ module Gitlab
end
def
self
.
connected?
G
itlab
::
Database
.
postgresql?
&&
G
eoNode
.
connected?
&&
GeoNode
.
table_exists?
GeoNode
.
connected?
&&
GeoNode
.
table_exists?
end
def
self
.
enabled?
...
...
ee/spec/lib/ee/gitlab/database_spec.rb
View file @
44d93595
...
...
@@ -35,28 +35,16 @@ describe Gitlab::Database do
end
describe
'.healthy?'
do
it
'returns true when
using MySQL
'
do
allow
(
described_class
).
to
receive
(
:postgresql
?
).
and_return
(
false
)
it
'returns true when
replication lag is not too great
'
do
allow
(
Postgresql
::
ReplicationSlot
).
to
receive
(
:lag_too_great
?
).
and_return
(
false
)
expect
(
described_class
.
healthy?
).
to
be_truthy
end
context
'when using PostgreSQL'
do
before
do
allow
(
described_class
).
to
receive
(
:postgresql?
).
and_return
(
true
)
end
it
'returns false when replication lag is too great'
do
allow
(
Postgresql
::
ReplicationSlot
).
to
receive
(
:lag_too_great?
).
and_return
(
true
)
it
'returns true when replication lag is not too great'
do
allow
(
Postgresql
::
ReplicationSlot
).
to
receive
(
:lag_too_great?
).
and_return
(
false
)
expect
(
described_class
.
healthy?
).
to
be_truthy
end
it
'returns false when replication lag is too great'
do
allow
(
Postgresql
::
ReplicationSlot
).
to
receive
(
:lag_too_great?
).
and_return
(
true
)
expect
(
described_class
.
healthy?
).
to
be_falsey
end
expect
(
described_class
.
healthy?
).
to
be_falsey
end
end
...
...
ee/spec/lib/gitlab/geo_spec.rb
View file @
44d93595
...
...
@@ -138,12 +138,6 @@ describe Gitlab::Geo, :geo, :request_store do
expect
(
described_class
.
connected?
).
to
be_falsey
end
it
'returns false when MySQL is in use'
do
allow
(
Gitlab
::
Database
).
to
receive
(
:postgresql?
)
{
false
}
expect
(
described_class
.
connected?
).
to
be_falsey
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