You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org> on 2025/09/09 16:28:45 UTC
[PR] KAFKA-19679: Fixed the regression in the metric calculation to avoid NoSuchElementException [kafka]
Nikita-Shupletsov opened a new pull request, #20512:
URL: https://github.com/apache/kafka/pull/20512
Reapplied the fix https://github.com/apache/kafka/pull/18771 to fix the regression introduced in https://github.com/apache/kafka/pull/20022
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax merged PR #20512:
URL: https://github.com/apache/kafka/pull/20512
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337342109
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
if (openIterators.size() == 1) {
Review Comment:
I don't think that's a problem. While stores are sharded, each shard is its own `StateStore` and thus has an own `OpenIterator` instance. Hence, `OpenIterator` should be used by a single `StreamsThreads` and there should not be any concurrent usage.
The concurrently issue we fixed in only for the metric, because `addOldestOpenIteratorGauge` registers the Gauge `(config, now) -> openIterators.first().startTimestamp()` (well, now `(config, now) -> oldestStartTimestamp.get()`) which could be used concurrently, when the metric is read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org>.
Nikita-Shupletsov commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337318316
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
if (openIterators.size() == 1) {
Review Comment:
I agree. there is a potential race condition here. I will take a closer look
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "stevenschlansker (via GitHub)" <gi...@apache.org>.
stevenschlansker commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337342464
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
Review Comment:
In practice, I doubt it matters much, which is why I called it a "nano" optimization. I leave it in your capable hands to decide if it is worth implementing :)
That said, we actually are having scalability issues regarding creating iterators at relatively high frequency - see https://issues.apache.org/jira/browse/KAFKA-19678
One of our data stores is used almost exclusively for range lookups which use iterators.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "stevenschlansker (via GitHub)" <gi...@apache.org>.
stevenschlansker commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337284038
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
if (openIterators.size() == 1) {
Review Comment:
Thinking about this more, I wonder if there is another possible race here that would not cause an exception but could cause missing or incorrectly persisting metrics. The OpenIterators tracker itself is not synchronized (good to avoid contention) but that means that we are mutating `add()` or `remove()` and calling `size()` expecting the results in program order.
But, I don't see any guarantee this is the case - my (limited) understanding is that OpenIterators is a property of a KeyValueStore, which may have partitions shared between threads.
Imagine:
```
T1: open iterator on store S1 (partition 0)
T2: open iterator on store S1 (partition 1)
T1: openIterators.add(it1)
T2: openIterators.add(it2)
T1: if (openIterators.size() == 1) { (2 == 1? nope)
T2: if (openIterators.size() == 1) { (2 == 1? nope)
End: 2 iterators open, no metric registered
```
Same race is possible with remove.
(This is a slightly different issue than originally reported, so if it's more appropriate to fix it with a different bug / PR, that's totally understandable)
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
Review Comment:
Possible nano-optimization: the oldest start timestamp will only change if this is the first open iterator - any other open iterator will definitionally be older - so we could possibly only update the oldest timestamp inside the `if (openIterators.size() == 1)` block below?
(assuming timestamps are all coming from the same time source)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337328688
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
Review Comment:
While I was reviewing the PR, I also though about this, but though it's not worth doing, as creating iterators should not happen with very high frequency?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Changed the calculation logic of oldest start timestamp to avoid NoSuchElementException [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2335235163
##########
streams/src/test/java/org/apache/kafka/streams/internals/metrics/OpenIteratorsTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.internals.metrics;
+
+import org.apache.kafka.common.metrics.Gauge;
+import org.apache.kafka.streams.processor.TaskId;
+import org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl;
+import org.apache.kafka.streams.state.internals.MeteredIterator;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+
+public class OpenIteratorsTest {
+
+ private final StreamsMetricsImpl streamsMetrics = mock(StreamsMetricsImpl.class);
+
+ @Test
Review Comment:
```suggestion
@SuppressWarnings("unchecked")
@Test
```
##########
streams/src/test/java/org/apache/kafka/streams/internals/metrics/OpenIteratorsTest.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.internals.metrics;
+
+import org.apache.kafka.common.metrics.Gauge;
+import org.apache.kafka.streams.processor.TaskId;
+import org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl;
+import org.apache.kafka.streams.state.internals.MeteredIterator;
+import org.junit.jupiter.api.Test;
+import org.mockito.ArgumentCaptor;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+
+public class OpenIteratorsTest {
+
+ private final StreamsMetricsImpl streamsMetrics = mock(StreamsMetricsImpl.class);
+
+ @Test
+ public void shouldCalculateOldestStartTimestampCorrectly() {
+ final OpenIterators openIterators = new OpenIterators(new TaskId(1, 1), "2", "3", streamsMetrics);
Review Comment:
```suggestion
final OpenIterators openIterators = new OpenIterators(new TaskId(0, 0), "scope", "name", streamsMetrics);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "stevenschlansker (via GitHub)" <gi...@apache.org>.
stevenschlansker commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337325325
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
Review Comment:
I am only referring to the `add()` flow - which will add 1, then add 2, then add 3 - and only the first operation may change the oldest iterator.
I agree in the `remove()` case we much check every time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on PR #20512:
URL: https://github.com/apache/kafka/pull/20512#issuecomment-3273287116
Oh. While trying to cherry-pick to `4.0` branch, I realize that `4.0.0` is not affected. We never cherry-picked to fix the "return null" issue (https://issues.apache.org/jira/browse/KAFKA-19398) to `4.0`.
So if we would want to fix in `4.0.1`, we would need to cherry-pick both commits. Might not be worth the trouble, given that a next RC is already lines up.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on PR #20512:
URL: https://github.com/apache/kafka/pull/20512#issuecomment-3273274297
Thanks for the PR @Nikita-Shupletsov! Merged to `trunk` and cherry-picked to `4.1` branch.
Congrats to your first contribution!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "stevenschlansker (via GitHub)" <gi...@apache.org>.
stevenschlansker commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337351407
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
if (openIterators.size() == 1) {
Review Comment:
OK, thanks for clarifying!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fixed the regression in the metric calculation to avoid NoSuchElementException [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2334202269
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -51,7 +52,10 @@ public void add(final MeteredIterator iterator) {
if (openIterators.size() == 1) {
metricName = StateStoreMetrics.addOldestOpenIteratorGauge(taskId.toString(), metricsScope, name, streamsMetrics,
- (config, now) -> openIterators.first().startTimestamp()
+ (config, now) -> {
+ final Iterator<MeteredIterator> openIteratorsIterator = openIterators.iterator();
+ return openIteratorsIterator.hasNext() ? openIteratorsIterator.next().startTimestamp() : null;
Review Comment:
I think we we ever want to return `null` -- that why we added dynamic register/deregister behavior.
I believe, we would need to somehow cache the "last result" before we remove the last iterator.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2335256270
##########
streams/src/test/java/org/apache/kafka/streams/internals/metrics/OpenIteratorsTest.java:
##########
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.streams.internals.metrics;
+
+import org.apache.kafka.common.metrics.Gauge;
+import org.apache.kafka.streams.processor.TaskId;
+import org.apache.kafka.streams.processor.internals.metrics.StreamsMetricsImpl;
+import org.apache.kafka.streams.state.internals.MeteredIterator;
+import org.junit.jupiter.api.Test;
Review Comment:
```suggestion
import org.junit.jupiter.api.Test;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "stevenschlansker (via GitHub)" <gi...@apache.org>.
stevenschlansker commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337325325
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
Review Comment:
I am only referring to the `add()` flow - which will add 1, then add 2, then add 3 - and only the first operation may change the oldest iterator.
I agree in the `remove()` case we must check every time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "mjsax (via GitHub)" <gi...@apache.org>.
mjsax commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337342109
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
if (openIterators.size() == 1) {
Review Comment:
I don't think that's a problem. While stores are sharded, each shard is its own `StateStore` and thus has an own `OpenIterator` instance. Hence, `OpenIterator` should be used by a single `StreamsThreads` and there should not be any concurrent usage.
The concurrently issue we fixed is only for the metric, because `addOldestOpenIteratorGauge` registers the Gauge `(config, now) -> openIterators.first().startTimestamp()` (well, now `(config, now) -> oldestStartTimestamp.get()`) which could be used concurrently, when the metric is read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "stevenschlansker (via GitHub)" <gi...@apache.org>.
stevenschlansker commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337284038
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
if (openIterators.size() == 1) {
Review Comment:
Thinking about this more, I wonder if there is another possible race here that would not cause an exception but could cause missing or incorrectly persisting metrics. The OpenIterators tracker itself is not synchronized (good to avoid contention) but that means that we are mutating `add()` or `remove()` and calling `size()` expecting the results in program order.
But, I don't see any guarantee this is the case - my (limited) understanding is that OpenIterators is a property of a KeyValueStore, which may have partitions shared between threads.
Imagine:
```
T1: open iterator on store S1 (partition 0)
T2: open iterator on store S1 (partition 1)
T1: openIterators.add(it1)
T2: openIterators.add(it2)
T1: if (openIterators.size() == 1) { (2 == 1? nope)
T2: if (openIterators.size() == 1) { (2 == 1? nope)
End: 2 iterators open, no metric registered
```
Same race is possible with remove.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Fix NoSuchElementException in oldest open iterator metric [kafka]
Posted by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org>.
Nikita-Shupletsov commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2337314055
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -48,10 +51,11 @@ public OpenIterators(final TaskId taskId,
public void add(final MeteredIterator iterator) {
openIterators.add(iterator);
+ updateOldestStartTimestamp();
Review Comment:
I am not 100% sure I understand the idea.
If we add 3 iterators with timestamps: 1, 2, 3
the result will be 1.
if we delete the first one, the result will be 2. the result changed, even though we still have more than 1 open iterator.
if I misunderstood the idea, please let me know
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-19679: Changed the calculation logic of oldest start timestamp to avoid NoSuchElementException [kafka]
Posted by "Nikita-Shupletsov (via GitHub)" <gi...@apache.org>.
Nikita-Shupletsov commented on code in PR #20512:
URL: https://github.com/apache/kafka/pull/20512#discussion_r2334607715
##########
streams/src/main/java/org/apache/kafka/streams/internals/metrics/OpenIterators.java:
##########
@@ -51,7 +52,10 @@ public void add(final MeteredIterator iterator) {
if (openIterators.size() == 1) {
metricName = StateStoreMetrics.addOldestOpenIteratorGauge(taskId.toString(), metricsScope, name, streamsMetrics,
- (config, now) -> openIterators.first().startTimestamp()
+ (config, now) -> {
+ final Iterator<MeteredIterator> openIteratorsIterator = openIterators.iterator();
+ return openIteratorsIterator.hasNext() ? openIteratorsIterator.next().startTimestamp() : null;
Review Comment:
good suggestion. I've updated the PR. please let me know if the changes make sense to you.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org