Commit a0e5260
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]>
1 parent 959a37f commit a0e5260
File tree
2 files changed
+20
-6
lines changed- logstash-core
- spec/logstash
- src/main/java/org/logstash/ackedqueue
2 files changed
+20
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
61 | 67 | | |
62 | 68 | | |
63 | 69 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
77 | 91 | | |
78 | 92 | | |
79 | 93 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
0 commit comments