-
Notifications
You must be signed in to change notification settings - Fork 3.5k
PQ settings refactor: propagate builder upward #18180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The `ackedqueue.SettingsImpl` uses an _immutable_ builder, which makes adding options cumbersome; each additional property added needs to modify code from all existing options. By introducing an api-internal temporary mutable builder, we can simplify the process of creating an immutable copy that has a single component modified.
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
|
This pull request does not have a backport label. Could you fix it @yaauie? 🙏
|
andsel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes seems fine, I left a question regarding the need to use a MutableBuilder bridge class to collect field values.
LMK your thoughts about that.
logstash-core/src/main/java/org/logstash/ackedqueue/SettingsImpl.java
Outdated
Show resolved
Hide resolved
logstash-core/src/main/java/org/logstash/ackedqueue/ext/JRubyWrappedAckedQueueExt.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Andrea Selva <[email protected]>
|
💚 Build Succeeded
History
|
andsel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
…8366) The queue factory setting "queueMaxBytes" used to be a long [link](https://github.com/elastic/logstash/pull/18180/files#diff-a377851670e06cd113751aa73b726b446dfb721d03d6979b9195afff7facd9f5L60): ```ruby long queueMaxBytes = RubyFixnum.num2long(args[6]); ``` But with the refactoring of #18180, it [became an Integer by mistake](https://github.com/elastic/logstash/pull/18180/files#diff-01eec670d2beabcd43041ff7fca8bc907eb227471dce886bb757b6414a655429R125): ```java .queueMaxBytes(getSetting(context, settings, QUEUE_MAX_BYTES).toJava(Integer.class)) ``` Which prevents queues being bigger than 2^31-1, causing crashes to anyone setting their PQ to 2GB or more: ```yaml queue.max_bytes: 2147483647 # 2GB-1 OK queue.max_bytes: 2147483648 # 2GB FAIL ``` This change makes queueMaxBytes a Long again, with a test confirming that queues larger than 2ˆ31-1 (max int) can be created. Without this change the new test fails: ``` ❯ bin/rspec logstash-core/spec/logstash/queue_factory_spec.rb ..F. Failures: 1) LogStash::QueueFactory when `queue.type` is `persisted` when queue.max_bytes is larger than Java int does not raise error Failure/Error: expect { queue = subject.create(settings) }.to_not raise_error expected no Exception, got #<RangeError: too big for int: 2147483648> with backtrace: # org/logstash/ackedqueue/QueueFactoryExt.java:97:in `create' # org/logstash/ackedqueue/QueueFactoryExt.java:88:in `create' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./lib/bootstrap/rspec.rb:36:in `<main>' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./lib/bootstrap/rspec.rb:36:in `<main>' Finished in 0.03879 seconds (files took 0.03787 seconds to load) 4 examples, 1 failure Failed examples: rspec ./logstash-core/spec/logstash/queue_factory_spec.rb:84 # LogStash::QueueFactory when `queue.type` is `persisted` when queue.max_bytes is larger than Java int does not raise error ``` But with the change it passes: ``` ❯ bin/rspec logstash-core/spec/logstash/queue_factory_spec.rb -fd LogStash::QueueFactory when `queue.type` is `persisted` returns a `WrappedAckedQueue` per pipeline id subdirectory creation creates a queue directory based on the pipeline id when queue.max_bytes is larger than Java int does not raise error when `queue.type` is `memory` returns a `WrappedSynchronousQueue` Finished in 0.03292 seconds (files took 0.04052 seconds to load) 4 examples, 0 failures ```
…8366) The queue factory setting "queueMaxBytes" used to be a long [link](https://github.com/elastic/logstash/pull/18180/files#diff-a377851670e06cd113751aa73b726b446dfb721d03d6979b9195afff7facd9f5L60): ```ruby long queueMaxBytes = RubyFixnum.num2long(args[6]); ``` But with the refactoring of #18180, it [became an Integer by mistake](https://github.com/elastic/logstash/pull/18180/files#diff-01eec670d2beabcd43041ff7fca8bc907eb227471dce886bb757b6414a655429R125): ```java .queueMaxBytes(getSetting(context, settings, QUEUE_MAX_BYTES).toJava(Integer.class)) ``` Which prevents queues being bigger than 2^31-1, causing crashes to anyone setting their PQ to 2GB or more: ```yaml queue.max_bytes: 2147483647 # 2GB-1 OK queue.max_bytes: 2147483648 # 2GB FAIL ``` This change makes queueMaxBytes a Long again, with a test confirming that queues larger than 2ˆ31-1 (max int) can be created. Without this change the new test fails: ``` ❯ bin/rspec logstash-core/spec/logstash/queue_factory_spec.rb ..F. Failures: 1) LogStash::QueueFactory when `queue.type` is `persisted` when queue.max_bytes is larger than Java int does not raise error Failure/Error: expect { queue = subject.create(settings) }.to_not raise_error expected no Exception, got #<RangeError: too big for int: 2147483648> with backtrace: # org/logstash/ackedqueue/QueueFactoryExt.java:97:in `create' # org/logstash/ackedqueue/QueueFactoryExt.java:88:in `create' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./lib/bootstrap/rspec.rb:36:in `<main>' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./lib/bootstrap/rspec.rb:36:in `<main>' Finished in 0.03879 seconds (files took 0.03787 seconds to load) 4 examples, 1 failure Failed examples: rspec ./logstash-core/spec/logstash/queue_factory_spec.rb:84 # LogStash::QueueFactory when `queue.type` is `persisted` when queue.max_bytes is larger than Java int does not raise error ``` But with the change it passes: ``` ❯ bin/rspec logstash-core/spec/logstash/queue_factory_spec.rb -fd LogStash::QueueFactory when `queue.type` is `persisted` returns a `WrappedAckedQueue` per pipeline id subdirectory creation creates a queue directory based on the pipeline id when queue.max_bytes is larger than Java int does not raise error when `queue.type` is `memory` returns a `WrappedSynchronousQueue` Finished in 0.03292 seconds (files took 0.04052 seconds to load) 4 examples, 0 failures ``` (cherry picked from commit 6c48e51)
…8366) (#18367) The queue factory setting "queueMaxBytes" used to be a long [link](https://github.com/elastic/logstash/pull/18180/files#diff-a377851670e06cd113751aa73b726b446dfb721d03d6979b9195afff7facd9f5L60): ```ruby long queueMaxBytes = RubyFixnum.num2long(args[6]); ``` But with the refactoring of #18180, it [became an Integer by mistake](https://github.com/elastic/logstash/pull/18180/files#diff-01eec670d2beabcd43041ff7fca8bc907eb227471dce886bb757b6414a655429R125): ```java .queueMaxBytes(getSetting(context, settings, QUEUE_MAX_BYTES).toJava(Integer.class)) ``` Which prevents queues being bigger than 2^31-1, causing crashes to anyone setting their PQ to 2GB or more: ```yaml queue.max_bytes: 2147483647 # 2GB-1 OK queue.max_bytes: 2147483648 # 2GB FAIL ``` This change makes queueMaxBytes a Long again, with a test confirming that queues larger than 2ˆ31-1 (max int) can be created. Without this change the new test fails: ``` ❯ bin/rspec logstash-core/spec/logstash/queue_factory_spec.rb ..F. Failures: 1) LogStash::QueueFactory when `queue.type` is `persisted` when queue.max_bytes is larger than Java int does not raise error Failure/Error: expect { queue = subject.create(settings) }.to_not raise_error expected no Exception, got #<RangeError: too big for int: 2147483648> with backtrace: # org/logstash/ackedqueue/QueueFactoryExt.java:97:in `create' # org/logstash/ackedqueue/QueueFactoryExt.java:88:in `create' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./lib/bootstrap/rspec.rb:36:in `<main>' # ./logstash-core/spec/logstash/queue_factory_spec.rb:85:in `block in <main>' # ./lib/bootstrap/rspec.rb:36:in `<main>' Finished in 0.03879 seconds (files took 0.03787 seconds to load) 4 examples, 1 failure Failed examples: rspec ./logstash-core/spec/logstash/queue_factory_spec.rb:84 # LogStash::QueueFactory when `queue.type` is `persisted` when queue.max_bytes is larger than Java int does not raise error ``` But with the change it passes: ``` ❯ bin/rspec logstash-core/spec/logstash/queue_factory_spec.rb -fd LogStash::QueueFactory when `queue.type` is `persisted` returns a `WrappedAckedQueue` per pipeline id subdirectory creation creates a queue directory based on the pipeline id when queue.max_bytes is larger than Java int does not raise error when `queue.type` is `memory` returns a `WrappedSynchronousQueue` Finished in 0.03292 seconds (files took 0.04052 seconds to load) 4 examples, 0 failures ``` (cherry picked from commit 6c48e51) Co-authored-by: João Duarte <[email protected]>





Release notes
[rn: skip]
What does this PR do?
This is an internal no-net-change refactor to pull upward the use of the
org.logstash.ackedqueue.Settingsinto the JRuby queue extension classes, pared off of the existing PR #18121.Why is it important/What is the impact to the user?
There is no net change to the user.
The changes here underly code that is also going to need changes in @andsel 's current in-flight work. Paring it off as a separate PR unblocks his work.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files (and/or docker env variables)[ ] I have added tests that prove my fix is effective or that my feature worksHow to test this PR locally
No net change. Rely on existing test coverage and usage.
Related issues
Use cases
Screenshots
Logs