Skip to content
Snippets Groups Projects

Resolve "Geo: Optimize replication of project repo keep around refs"

Files
2
@@ -60,14 +60,18 @@ def up_to_date_with_upstream?(branch_name)
def keep_around(*shas)
super
ensure
# The keep_around method is called from different places. One of them
# is when a pipeline is created. So, in this case, it is still under
# Ci::Pipeline.transaction. It's safe to skip the transaction check
# because we already wrote the refs to the repository on disk.
Sidekiq::Worker.skipping_transaction_check do
::Gitlab::EventStore.publish(
::Repositories::KeepAroundRefsCreatedEvent.new(data: { project_id: project.id })
)
# If there are no SHAs received then there is no write_ref executed.
# The following condition avoids to publish unnecessary events.
if shas.compact.any?
# The keep_around method is called from different places. One of them
# is when a pipeline is created. So, in this case, it is still under
# Ci::Pipeline.transaction. It's safe to skip the transaction check
# because we already wrote the refs to the repository on disk.
Sidekiq::Worker.skipping_transaction_check do
::Gitlab::EventStore.publish(
::Repositories::KeepAroundRefsCreatedEvent.new(data: { project_id: project.id })
)
end
end
end
Loading