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

EE: Remove dead MySQL code

parent ef1efa0f
...@@ -52,10 +52,7 @@ module EE ...@@ -52,10 +52,7 @@ module EE
scope :inc_group, -> { includes(:group) } scope :inc_group, -> { includes(:group) }
scope :order_start_or_end_date_asc, -> do scope :order_start_or_end_date_asc, -> do
# mysql returns null values first in opposite to postgres which reorder("COALESCE(start_date, end_date) ASC NULLS FIRST")
# returns them last by default
nulls_first = ::Gitlab::Database.postgresql? ? 'NULLS FIRST' : ''
reorder("COALESCE(start_date, end_date) ASC #{nulls_first}")
end end
scope :order_start_date_asc, -> do scope :order_start_date_asc, -> do
...@@ -170,9 +167,6 @@ module EE ...@@ -170,9 +167,6 @@ module EE
end end
def update_start_and_due_dates(epics) 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( self.where(id: epics).update_all(
[ [
%{ %{
......
...@@ -10,14 +10,11 @@ class ClearSharedRunnersMinutesWorker ...@@ -10,14 +10,11 @@ class ClearSharedRunnersMinutesWorker
def perform def perform
return unless try_obtain_lease return unless try_obtain_lease
if Gitlab::Database.postgresql? Namespace.with_shared_runners_minutes_limit
# Using UPDATE with a joined table is not supported in MySql .with_extra_shared_runners_minutes_limit
Namespace.with_shared_runners_minutes_limit .where('namespace_statistics.namespace_id = namespaces.id')
.with_extra_shared_runners_minutes_limit .where('namespace_statistics.shared_runners_seconds > (namespaces.shared_runners_minutes_limit * 60)')
.where('namespace_statistics.namespace_id = namespaces.id') .update_all("extra_shared_runners_minutes_limit = #{extra_minutes_left_sql} FROM namespace_statistics")
.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.where('last_ci_minutes_notification_at IS NOT NULL OR last_ci_minutes_usage_notification_level IS NOT NULL') Namespace.where('last_ci_minutes_notification_at IS NOT NULL OR last_ci_minutes_usage_notification_level IS NOT NULL')
.each_batch do |relation| .each_batch do |relation|
......
...@@ -10,32 +10,18 @@ module EE ...@@ -10,32 +10,18 @@ module EE
def move_attributes_data_to_project(start_id, end_id) 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 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
ActiveRecord::Base.connection.execute <<~SQL UPDATE projects
UPDATE projects, project_mirror_data SET
SET import_status = project_mirror_data.status,
projects.import_status = project_mirror_data.status, import_jid = project_mirror_data.jid,
projects.import_jid = project_mirror_data.jid, mirror_last_update_at = project_mirror_data.last_update_at,
projects.mirror_last_update_at = project_mirror_data.last_update_at, mirror_last_successful_update_at = project_mirror_data.last_successful_update_at,
projects.mirror_last_successful_update_at = project_mirror_data.last_successful_update_at, import_error = project_mirror_data.last_error
projects.import_error = project_mirror_data.last_error FROM project_mirror_data
WHERE project_mirror_data.project_id = projects.id WHERE project_mirror_data.project_id = projects.id
AND project_mirror_data.id BETWEEN #{start_id} AND #{end_id} AND project_mirror_data.id BETWEEN #{start_id} AND #{end_id}
SQL 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
end end
end end
end end
......
...@@ -14,8 +14,6 @@ module EE ...@@ -14,8 +14,6 @@ module EE
end end
def healthy? def healthy?
return true unless postgresql?
!Postgresql::ReplicationSlot.lag_too_great? !Postgresql::ReplicationSlot.lag_too_great?
end end
......
...@@ -29,7 +29,7 @@ module Gitlab ...@@ -29,7 +29,7 @@ module Gitlab
end end
def self.connected? def self.connected?
Gitlab::Database.postgresql? && GeoNode.connected? && GeoNode.table_exists? GeoNode.connected? && GeoNode.table_exists?
end end
def self.enabled? def self.enabled?
......
...@@ -35,28 +35,16 @@ describe Gitlab::Database do ...@@ -35,28 +35,16 @@ describe Gitlab::Database do
end end
describe '.healthy?' do describe '.healthy?' do
it 'returns true when using MySQL' do it 'returns true when replication lag is not too great' do
allow(described_class).to receive(:postgresql?).and_return(false) allow(Postgresql::ReplicationSlot).to receive(:lag_too_great?).and_return(false)
expect(described_class.healthy?).to be_truthy expect(described_class.healthy?).to be_truthy
end end
context 'when using PostgreSQL' do it 'returns false when replication lag is too great' do
before do allow(Postgresql::ReplicationSlot).to receive(:lag_too_great?).and_return(true)
allow(described_class).to receive(:postgresql?).and_return(true)
end
it 'returns true when replication lag is not too great' do expect(described_class.healthy?).to be_falsey
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
end end
end end
......
...@@ -138,12 +138,6 @@ describe Gitlab::Geo, :geo, :request_store do ...@@ -138,12 +138,6 @@ describe Gitlab::Geo, :geo, :request_store do
expect(described_class.connected?).to be_falsey expect(described_class.connected?).to be_falsey
end 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
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