summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/application_setting.rb2
-rw-r--r--changelogs/unreleased/199422-maximum-size-for-gitlab-pages-says-to-set-it-to-0-for-unlimited-bu.yml5
-rw-r--r--changelogs/unreleased/share-redis-cache-connection-pool.yml5
-rw-r--r--config/application.rb11
-rw-r--r--lib/gitlab/import_export/json/streaming_serializer.rb10
-rw-r--r--lib/gitlab/redis/wrapper.rb5
-rw-r--r--spec/models/application_setting_spec.rb8
7 files changed, 27 insertions, 19 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 3d55269e36f..64ca7446fa5 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -137,7 +137,7 @@ class ApplicationSetting < ApplicationRecord
validates :max_pages_size,
presence: true,
- numericality: { only_integer: true, greater_than: 0,
+ numericality: { only_integer: true, greater_than_or_equal_to: 0,
less_than: ::Gitlab::Pages::MAX_SIZE / 1.megabyte }
validates :default_artifacts_expire_in, presence: true, duration: true
diff --git a/changelogs/unreleased/199422-maximum-size-for-gitlab-pages-says-to-set-it-to-0-for-unlimited-bu.yml b/changelogs/unreleased/199422-maximum-size-for-gitlab-pages-says-to-set-it-to-0-for-unlimited-bu.yml
new file mode 100644
index 00000000000..2942943a482
--- /dev/null
+++ b/changelogs/unreleased/199422-maximum-size-for-gitlab-pages-says-to-set-it-to-0-for-unlimited-bu.yml
@@ -0,0 +1,5 @@
+---
+title: Allow 0 for pages size limit setting in admin settings
+merge_request: 28086
+author:
+type: fixed
diff --git a/changelogs/unreleased/share-redis-cache-connection-pool.yml b/changelogs/unreleased/share-redis-cache-connection-pool.yml
new file mode 100644
index 00000000000..7463b6aa777
--- /dev/null
+++ b/changelogs/unreleased/share-redis-cache-connection-pool.yml
@@ -0,0 +1,5 @@
+---
+title: Make Rails.cache and Gitlab::Redis::Cache share the same Redis connection pool
+merge_request: 28074
+author:
+type: performance
diff --git a/config/application.rb b/config/application.rb
index 8cd707c9e15..5c4eb8f5dff 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -258,18 +258,11 @@ module Gitlab
# Use caching across all environments
# Full list of options:
# https://api.rubyonrails.org/classes/ActiveSupport/Cache/RedisCacheStore.html#method-c-new
- caching_config_hash = Gitlab::Redis::Cache.params
+ caching_config_hash = {}
+ caching_config_hash[:redis] = Gitlab::Redis::Cache.pool
caching_config_hash[:compress] = Gitlab::Utils.to_boolean(ENV.fetch('ENABLE_REDIS_CACHE_COMPRESSION', '1'))
caching_config_hash[:namespace] = Gitlab::Redis::Cache::CACHE_NAMESPACE
caching_config_hash[:expires_in] = 2.weeks # Cache should not grow forever
- if Gitlab::Runtime.multi_threaded?
- caching_config_hash[:pool_size] = Gitlab::Redis::Cache.pool_size
- caching_config_hash[:pool_timeout] = 1
- end
-
- # Overrides RedisCacheStore's default value of 0
- # This makes the default value the same with Gitlab::Redis::Cache
- caching_config_hash[:reconnect_attempts] ||= ::Redis::Client::DEFAULTS[:reconnect_attempts]
config.cache_store = :redis_cache_store, caching_config_hash
diff --git a/lib/gitlab/import_export/json/streaming_serializer.rb b/lib/gitlab/import_export/json/streaming_serializer.rb
index 04ca598ff5d..7f55a0a3821 100644
--- a/lib/gitlab/import_export/json/streaming_serializer.rb
+++ b/lib/gitlab/import_export/json/streaming_serializer.rb
@@ -69,11 +69,13 @@ module Gitlab
end
def serialize_many_each(key, records, options)
- records.each do |record|
- json = Raw.new(record.to_json(options))
-
- json_writer.append(key, json)
+ enumerator = Enumerator.new do |items|
+ records.each do |record|
+ items << Raw.new(record.to_json(options))
+ end
end
+
+ json_writer.write_relation_array(@exportable_path, key, enumerator)
end
def serialize_single_relation(key, record, options)
diff --git a/lib/gitlab/redis/wrapper.rb b/lib/gitlab/redis/wrapper.rb
index c8932b26925..06ee81ba172 100644
--- a/lib/gitlab/redis/wrapper.rb
+++ b/lib/gitlab/redis/wrapper.rb
@@ -15,8 +15,11 @@ module Gitlab
delegate :params, :url, to: :new
def with
+ pool.with { |redis| yield redis }
+ end
+
+ def pool
@pool ||= ConnectionPool.new(size: pool_size) { ::Redis.new(params) }
- @pool.with { |redis| yield redis }
end
def pool_size
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 4c96b0079df..8307f91dfed 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -69,12 +69,12 @@ describe ApplicationSetting do
it { is_expected.to validate_numericality_of(:snippet_size_limit).only_integer.is_greater_than(0) }
it { is_expected.to validate_presence_of(:max_artifacts_size) }
- it do
- is_expected.to validate_numericality_of(:max_pages_size).only_integer.is_greater_than(0)
+ it { is_expected.to validate_numericality_of(:max_artifacts_size).only_integer.is_greater_than(0) }
+ it { is_expected.to validate_presence_of(:max_pages_size) }
+ it 'ensures max_pages_size is an integer greater than 0 (or equal to 0 to indicate unlimited/maximum)' do
+ is_expected.to validate_numericality_of(:max_pages_size).only_integer.is_greater_than_or_equal_to(0)
.is_less_than(::Gitlab::Pages::MAX_SIZE / 1.megabyte)
end
- it { is_expected.to validate_numericality_of(:max_artifacts_size).only_integer.is_greater_than(0) }
- it { is_expected.to validate_numericality_of(:max_pages_size).only_integer.is_greater_than(0) }
it { is_expected.not_to allow_value(7).for(:minimum_password_length) }
it { is_expected.not_to allow_value(129).for(:minimum_password_length) }