Skip to content

Commit 75776b0

Browse files
author
GitLab Bot
committed
Add latest changes from gitlab-org/gitlab@master
1 parent fdb478e commit 75776b0

40 files changed

+322
-411
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ gem 'browser', '~> 5.3.1'
113113
gem 'ohai', '~> 17.9'
114114

115115
# GPG
116-
gem 'gpgme', '~> 2.0.22'
116+
gem 'gpgme', '~> 2.0.23'
117117

118118
# LDAP Auth
119119
# GitLab fork with several improvements to original library. For full list of changes
@@ -493,7 +493,7 @@ group :test do
493493
# Moved in `test` because https://gitlab.com/gitlab-org/gitlab/-/issues/217527
494494
gem 'derailed_benchmarks', require: false
495495

496-
gem 'gitlab_quality-test_tooling', '~> 0.9.3', require: false
496+
gem 'gitlab_quality-test_tooling', '~> 1.0.0', require: false
497497
end
498498

499499
gem 'octokit', '~> 6.0'

Gemfile.checksum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
{"name":"gitlab-styles","version":"10.1.0","platform":"ruby","checksum":"f42745f5397d042fe24cf2d0eb56c995b37f9f43d8fb79b834d197a1cafdc84a"},
220220
{"name":"gitlab_chronic_duration","version":"0.11.0","platform":"ruby","checksum":"c2fd201724a9031ff0af23d07a30231cebefbf83c3e682daae452cda5f514ba6"},
221221
{"name":"gitlab_omniauth-ldap","version":"2.2.0","platform":"ruby","checksum":"bb4d20acb3b123ed654a8f6a47d3fac673ece7ed0b6992edb92dca14bad2838c"},
222-
{"name":"gitlab_quality-test_tooling","version":"0.9.3","platform":"ruby","checksum":"9751f3504b717499588bd0fa5517de9b6756e8b9548777ea0283b889694580f0"},
222+
{"name":"gitlab_quality-test_tooling","version":"1.0.0","platform":"ruby","checksum":"b030be168a6a0eb3c47202beb6c64a4fbe36f5547d189c3f64cad29cfcc331db"},
223223
{"name":"globalid","version":"1.1.0","platform":"ruby","checksum":"b337e1746f0c8cb0a6c918234b03a1ddeb4966206ce288fbb57779f59b2d154f"},
224224
{"name":"gon","version":"6.4.0","platform":"ruby","checksum":"e3a618d659392890f1aa7db420f17c75fd7d35aeb5f8fe003697d02c4b88d2f0"},
225225
{"name":"google-apis-androidpublisher_v3","version":"0.34.0","platform":"ruby","checksum":"d7e1d7dd92f79c498fe2082222a1740d788e022e660c135564b3fd299cab5425"},
@@ -255,7 +255,7 @@
255255
{"name":"googleapis-common-protos","version":"1.4.0","platform":"ruby","checksum":"da2380fb5ab1563580816c74e8d684ac17512c3654c829a3ee84f6d6139de382"},
256256
{"name":"googleapis-common-protos-types","version":"1.5.0","platform":"ruby","checksum":"5769cf7376abc86ef7f5897a4aaca1d5c5a3c49ddabeddd2c251fcf8155f858b"},
257257
{"name":"googleauth","version":"1.3.0","platform":"ruby","checksum":"51dd7362353cf1e90a2d01e1fb94321ae3926c776d4dc4a79db65230217ffcc2"},
258-
{"name":"gpgme","version":"2.0.22","platform":"ruby","checksum":"7c6904952afdd0bf2c7c3ed6de98a5143f86c6b7390dbcd9d7012bddfa3ec862"},
258+
{"name":"gpgme","version":"2.0.23","platform":"ruby","checksum":"c87bbafdb8719da7c58ebcac08297aa1fb227022ac6cd2972829ba68adc91c04"},
259259
{"name":"grape","version":"1.7.1","platform":"ruby","checksum":"6b679d8918ee3dc19b0da95a5069dc95a71a15cf5788f5f787bb2ededf58cbb6"},
260260
{"name":"grape-entity","version":"0.10.0","platform":"ruby","checksum":"9aed1e7cbbc96d9e73f72e5f32c776d4ba8a5baf54c3acda2682008dba2b2cfe"},
261261
{"name":"grape-path-helpers","version":"1.7.1","platform":"ruby","checksum":"2e27271a20d4073e3a3b2b955425c7f803e198be3ba8f6e59e3d59643c5381e2"},

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ GEM
685685
omniauth (>= 1.3, < 3)
686686
pyu-ruby-sasl (>= 0.0.3.3, < 0.1)
687687
rubyntlm (~> 0.5)
688-
gitlab_quality-test_tooling (0.9.3)
688+
gitlab_quality-test_tooling (1.0.0)
689689
activesupport (>= 6.1, < 7.1)
690690
gitlab (~> 4.19)
691691
http (~> 5.0)
@@ -769,7 +769,7 @@ GEM
769769
multi_json (~> 1.11)
770770
os (>= 0.9, < 2.0)
771771
signet (>= 0.16, < 2.a)
772-
gpgme (2.0.22)
772+
gpgme (2.0.23)
773773
mini_portile2 (~> 2.7)
774774
grape (1.7.1)
775775
activesupport
@@ -1834,7 +1834,7 @@ DEPENDENCIES
18341834
gitlab-utils!
18351835
gitlab_chronic_duration (~> 0.11)
18361836
gitlab_omniauth-ldap (~> 2.2.0)
1837-
gitlab_quality-test_tooling (~> 0.9.3)
1837+
gitlab_quality-test_tooling (~> 1.0.0)
18381838
gon (~> 6.4.0)
18391839
google-apis-androidpublisher_v3 (~> 0.34.0)
18401840
google-apis-cloudbilling_v1 (~> 0.21.0)
@@ -1848,7 +1848,7 @@ DEPENDENCIES
18481848
google-apis-sqladmin_v1beta4 (~> 0.41.0)
18491849
google-cloud-storage (~> 1.44.0)
18501850
google-protobuf (~> 3.24, >= 3.24.3)
1851-
gpgme (~> 2.0.22)
1851+
gpgme (~> 2.0.23)
18521852
grape (~> 1.7.1)
18531853
grape-entity (~> 0.10.0)
18541854
grape-path-helpers (~> 1.7.1)

app/models/concerns/cross_database_ignored_tables.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ module CrossDatabaseIgnoredTables
44
extend ActiveSupport::Concern
55

66
class_methods do
7+
def temporary_ignore_cross_database_tables(tables, url:, &blk)
8+
Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction(
9+
tables, url: url, &blk
10+
)
11+
end
12+
713
def cross_database_ignore_tables(tables, options = {})
814
raise "missing issue url" if options[:url].blank?
915

@@ -40,8 +46,7 @@ def temporary_ignore_cross_database_tables(tables, options, &blk)
4046
return yield unless options[:if].nil? || instance_eval(&options[:if])
4147

4248
url = options[:url]
43-
Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction(
44-
tables, url: url, &blk
45-
)
49+
50+
self.class.temporary_ignore_cross_database_tables(tables, url: url, &blk)
4651
end
4752
end

app/models/concerns/storage/legacy_namespace.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ def move_dir
1717
Namespace.find(parent_id_before_last_save) # raise NotFound early if needed
1818
end
1919

20-
move_repositories
21-
2220
if saved_change_to_parent?
2321
former_parent_full_path = parent_was&.full_path
2422
parent_full_path = parent&.full_path

app/models/members/group_member.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class GroupMember < Member
99

1010
belongs_to :group, foreign_key: 'source_id'
1111
alias_attribute :namespace_id, :source_id
12-
delegate :update_two_factor_requirement, to: :user, allow_nil: true
1312

1413
# Make sure group member points only to group as it source
1514
attribute :source_type, default: SOURCE_TYPE
@@ -26,6 +25,16 @@ class GroupMember < Member
2625

2726
attr_accessor :last_owner
2827

28+
def update_two_factor_requirement
29+
return unless user
30+
31+
Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction(
32+
%w[users user_details user_preferences], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424288'
33+
) do
34+
user.update_two_factor_requirement
35+
end
36+
end
37+
2938
# For those who get to see a modal with a role dropdown, here are the options presented
3039
def self.permissible_access_level_roles(_, _)
3140
# This method is a stopgap in preparation for https://gitlab.com/gitlab-org/gitlab/-/issues/364087

app/models/namespace.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Namespace < ApplicationRecord
1717
include BlocksUnsafeSerialization
1818
include Ci::NamespaceSettings
1919
include Referable
20+
include CrossDatabaseIgnoredTables
21+
22+
cross_database_ignore_tables %w[routes redirect_routes], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424277'
2023

2124
# Tells ActiveRecord not to store the full class name, in order to save some space
2225
# https://gitlab.com/gitlab-org/gitlab/-/merge_requests/69794
@@ -145,7 +148,6 @@ class Namespace < ApplicationRecord
145148
after_update :force_share_with_group_lock_on_descendants, if: -> { saved_change_to_share_with_group_lock? && share_with_group_lock? }
146149
after_update :expire_first_auto_devops_config_cache, if: -> { saved_change_to_auto_devops_enabled? }
147150
after_update :move_dir, if: :saved_change_to_path_or_parent?, unless: -> { is_a?(Namespaces::ProjectNamespace) }
148-
after_destroy :rm_dir
149151

150152
after_save :reload_namespace_details
151153

@@ -155,7 +157,6 @@ class Namespace < ApplicationRecord
155157

156158
# Legacy Storage specific hooks
157159

158-
before_destroy(prepend: true) { prepare_for_destroy }
159160
after_commit :expire_child_caches, on: :update, if: -> {
160161
Feature.enabled?(:cached_route_lookups, self, type: :ops) &&
161162
saved_change_to_name? || saved_change_to_path? || saved_change_to_parent_id?

app/models/namespace/traversal_hierarchy.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,16 @@ def sync_traversal_ids!
3939
AND namespaces.traversal_ids::bigint[] <> cte.traversal_ids
4040
SQL
4141

42-
Namespace.transaction do
43-
@root.lock!("FOR NO KEY UPDATE")
44-
Namespace.connection.exec_query(sql)
42+
# Hint: when a user is created, it also creates a Namespaces::UserNamespace in
43+
# `ensure_namespace_correct`. This method is then called within the same
44+
# transaction of the user INSERT.
45+
Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction(
46+
%w[namespaces], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424279'
47+
) do
48+
Namespace.transaction do
49+
@root.lock!("FOR NO KEY UPDATE")
50+
Namespace.connection.exec_query(sql)
51+
end
4552
end
4653
rescue ActiveRecord::Deadlocked
4754
db_deadlock_counter.increment(source: 'Namespace#sync_traversal_ids!')

app/models/project.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ class Project < ApplicationRecord
4444
include IssueParent
4545
include UpdatedAtFilterable
4646
include IgnorableColumns
47+
include CrossDatabaseIgnoredTables
4748

4849
ignore_column :emails_disabled, remove_with: '16.3', remove_after: '2023-08-22'
4950

51+
cross_database_ignore_tables %w[routes redirect_routes], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424277'
52+
5053
extend Gitlab::Cache::RequestCache
5154
extend Gitlab::Utils::Override
5255

app/models/user.rb

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class User < MainClusterwide::ApplicationRecord
3030
include RestrictedSignup
3131
include StripAttribute
3232
include EachBatch
33+
include CrossDatabaseIgnoredTables
3334
include IgnorableColumns
3435

3536
ignore_column %i[
@@ -39,6 +40,19 @@ class User < MainClusterwide::ApplicationRecord
3940
email_opted_in_at
4041
], remove_with: '16.6', remove_after: '2023-10-22'
4142

43+
# `ensure_namespace_correct` needs to be moved to an after_commit (?)
44+
cross_database_ignore_tables %w[namespaces namespace_settings], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424279'
45+
46+
# `notification_settings_for` is called, and elsewhere `save` is then called.
47+
cross_database_ignore_tables %w[notification_settings], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424284'
48+
49+
# Associations with dependent: option
50+
cross_database_ignore_tables(
51+
%w[namespaces projects project_authorizations issues merge_requests merge_requests issues issues merge_requests],
52+
url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424285',
53+
on: :destroy
54+
)
55+
4256
DEFAULT_NOTIFICATION_LEVEL = :participating
4357

4458
INSTANCE_ACCESS_REQUEST_APPROVERS_TO_BE_NOTIFIED_LIMIT = 10
@@ -348,7 +362,9 @@ def update_tracked_fields!(request)
348362
email_to_confirm.confirm
349363
end
350364
else
351-
add_primary_email_to_emails!
365+
ignore_cross_database_tables_if_factory_bot(%w[emails]) do
366+
add_primary_email_to_emails!
367+
end
352368
end
353369
end
354370
after_commit(on: :update) do
@@ -503,11 +519,19 @@ def blocked?
503519
end
504520

505521
after_transition any => :active do |user|
506-
user.starred_projects.update_counters(star_count: 1)
522+
user.class.temporary_ignore_cross_database_tables(
523+
%w[projects], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424278'
524+
) do
525+
user.starred_projects.update_counters(star_count: 1)
526+
end
507527
end
508528

509529
after_transition active: any do |user|
510-
user.starred_projects.update_counters(star_count: -1)
530+
user.class.temporary_ignore_cross_database_tables(
531+
%w[projects], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424278'
532+
) do
533+
user.starred_projects.update_counters(star_count: -1)
534+
end
511535
end
512536
end
513537

0 commit comments

Comments
 (0)