Commit 44d93595 authored by Nick Thomas's avatar Nick Thomas

EE: Remove dead MySQL code

parent ef1efa0f
......@@ -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(
[
%{
......
......@@ -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|
......
......@@ -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
......
......@@ -14,8 +14,6 @@ module EE
end
def healthy?
return true unless postgresql?
!Postgresql::ReplicationSlot.lag_too_great?
end
......
......@@ -29,7 +29,7 @@ module Gitlab
end
def self.connected?
Gitlab::Database.postgresql? && GeoNode.connected? && GeoNode.table_exists?
GeoNode.connected? && GeoNode.table_exists?
end
def self.enabled?
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment