diff --git a/ee/spec/services/vulnerability_exports/export_service_spec.rb b/ee/spec/services/vulnerability_exports/export_service_spec.rb
index 26d10edc96c5b3250eb99c5e9b3e33c02fcb7740..a9165ff977f816dff0c4e741fc349b6ff6c25a54 100644
--- a/ee/spec/services/vulnerability_exports/export_service_spec.rb
+++ b/ee/spec/services/vulnerability_exports/export_service_spec.rb
@@ -42,7 +42,10 @@
         export_segment
       end.count
 
-      expect(query_count).to eq(expected_export_query_count)
+      # In single DB mode some queries may be concatenated, resulting in less than the expected
+      # query count, so we permit less to cover this.
+      # See https://gitlab.com/gitlab-org/gitlab/-/issues/524755
+      expect(query_count).to be <= expected_export_query_count
     end
   end
 
@@ -270,7 +273,7 @@
           export
         end.count
 
-        expect(query_count).to eq(12)
+        expect(query_count).to be <= 12
       end
 
       it 'sets organization_id appropriately' do
diff --git a/spec/keeps/overdue_finalize_background_migration_spec.rb b/spec/keeps/overdue_finalize_background_migration_spec.rb
index 1025ee183318ed88bc882c08868cbf65fa2fc9ec..bab19213410365a63191f57f0531ed4b3b15f625 100644
--- a/spec/keeps/overdue_finalize_background_migration_spec.rb
+++ b/spec/keeps/overdue_finalize_background_migration_spec.rb
@@ -120,11 +120,17 @@
       end
     end
 
-    context 'when schema is gitlab_ci' do
-      let(:gitlab_schema) { 'gitlab_ci' }
+    context 'when using multiple databases' do
+      before do
+        skip_if_shared_database(:ci)
+      end
 
-      it 'returns the database name' do
-        expect(database_name).to eq(database_exists?(:ci) ? 'ci' : 'main')
+      context 'when schema is gitlab_ci' do
+        let(:gitlab_schema) { 'gitlab_ci' }
+
+        it 'returns the database name' do
+          expect(database_name).to eq('ci')
+        end
       end
     end
   end