Commit de145876 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Add a limit of LFS oids to be linked at once

This limits the number of object ids that would be linked at once. We
only noticed a problem before with 30_000 oids, this limit is well
beyond that and with the updated queries we should be able to handle
that.
parent 2edf27ea
......@@ -4,6 +4,9 @@
module Projects
module LfsPointers
class LfsLinkService < BaseService
TooManyOidsError = Class.new(StandardError)
MAX_OIDS = 100_000
BATCH_SIZE = 1000
# Accept an array of oids to link
......@@ -12,6 +15,10 @@ module Projects
def execute(oids)
return [] unless project&.lfs_enabled?
if oids.size > MAX_OIDS
raise TooManyOidsError, 'Too many LFS object ids to link, please push them manually'
end
# Search and link existing LFS Object
link_existing_lfs_objects(oids)
end
......
---
title: Improve performance of linking LFS objects during import
merge_request: 19709
author:
type: performance
......@@ -16,6 +16,13 @@ describe Projects::LfsPointers::LfsLinkService do
end
describe '#execute' do
it 'raises an error when trying to link too many objects at once' do
oids = Array.new(described_class::MAX_OIDS) { |i| "oid-#{i}" }
oids << 'the straw'
expect { subject.execute(oids) }.to raise_error(described_class::TooManyOidsError)
end
it 'links existing lfs objects to the project' do
expect(project.all_lfs_objects.count).to eq 2
......
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