You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "skorotkov (via GitHub)" <gi...@apache.org> on 2024/12/12 15:16:09 UTC
[PR] IGNITE-23971 Fix striped queue overflow in ScanQuery for caches with touched or accessed TTL expire policy [ignite]
skorotkov opened a new pull request, #11736:
URL: https://github.com/apache/ignite/pull/11736
…touched or accessed TTL expire policy
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
### The Contribution Checklist
- [ ] There is a single JIRA ticket related to the pull request.
- [ ] The web-link to the pull request is attached to the JIRA ticket.
- [ ] The JIRA ticket has the _Patch Available_ state.
- [ ] The pull request body describes changes that have been made.
The description explains _WHAT_ and _WHY_ was made instead of _HOW_.
- [ ] The pull request title is treated as the final commit message.
The following pattern must be used: `IGNITE-XXXX Change summary` where `XXXX` - number of JIRA issue.
- [ ] A reviewer has been mentioned through the JIRA comments
(see [the Maintainers list](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute#HowtoContribute-ReviewProcessandMaintainers))
- [ ] The pull request has been checked by the Teamcity Bot and
the `green visa` attached to the JIRA ticket (see [TC.Bot: Check PR](https://mtcga.gridgain.com/prs.html))
### Notes
- [How to Contribute](https://cwiki.apache.org/confluence/display/IGNITE/How+to+Contribute)
- [Coding abbreviation rules](https://cwiki.apache.org/confluence/display/IGNITE/Abbreviation+Rules)
- [Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Coding+Guidelines)
- [Apache Ignite Teamcity Bot](https://cwiki.apache.org/confluence/display/IGNITE/Apache+Ignite+Teamcity+Bot)
If you need any help, please email dev@ignite.apache.org or ask anу advice on http://asf.slack.com _#ignite_ channel.
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23971 Fix striped queue overflow in ScanQuery for caches with touched or accessed TTL expire policy [ignite]
Posted by "alex-plekhanov (via GitHub)" <gi...@apache.org>.
alex-plekhanov commented on code in PR #11736:
URL: https://github.com/apache/ignite/pull/11736#discussion_r1895833526
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java:
##########
@@ -1365,12 +1365,16 @@ private void sendTtlUpdateRequest(
@Nullable UUID srcNodeId
) {
if (!F.isEmpty(expiryPlc.entries())) {
+ Map<KeyCacheObject, GridCacheVersion> entries = Map.copyOf(expiryPlc.entries());
+
+ assert entries != null && !entries.isEmpty();
Review Comment:
1. Can be replaced with `!F.isEmpty(entries)`
2. Already checked two lines before and looks like can't be modified concurrently now
##########
modules/indexing/src/test/java/org/apache/ignite/testsuites/IgniteBinaryCacheQueryTestSuite4.java:
##########
@@ -101,6 +102,8 @@
ScanQueryTransactionsUnsupportedModesTest.class,
ScanQueryTransactionIsolationTest.class,
+
+ ScanQueryUpdateTtlTest.class,
Review Comment:
It's strange that we have all scan-query tests in indexing-module suite. Looks like they are not related to indexing and should be in core-module. But ok, let's keep it as is.
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java:
##########
@@ -1365,12 +1365,16 @@ private void sendTtlUpdateRequest(
@Nullable UUID srcNodeId
) {
if (!F.isEmpty(expiryPlc.entries())) {
+ Map<KeyCacheObject, GridCacheVersion> entries = Map.copyOf(expiryPlc.entries());
+
+ assert entries != null && !entries.isEmpty();
+
+ Map<UUID, Collection<IgniteBiTuple<KeyCacheObject, GridCacheVersion>>> rdrs =
+ expiryPlc.readers() != null ? Map.copyOf(expiryPlc.readers()) : null;
+
ctx.closures().runLocalSafe(new GridPlainRunnable() {
@SuppressWarnings({"ForLoopReplaceableByForEach"})
@Override public void run() {
- Map<KeyCacheObject, GridCacheVersion> entries = expiryPlc.entries();
-
- assert entries != null && !entries.isEmpty();
Review Comment:
Redundant NL
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/ScanQueryUpdateTtlTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.ignite.internal.processors.cache.query;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import javax.cache.expiry.Duration;
+import javax.cache.expiry.TouchedExpiryPolicy;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.distributed.GridCacheTtlUpdateRequest;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.processors.cache.query.ScanQueryIterator.EXPIRE_ENTRIES_FLUSH_CNT;
+
+/** */
+public class ScanQueryUpdateTtlTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS = EXPIRE_ENTRIES_FLUSH_CNT * 3;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ if (!cfg.isClientMode()) {
+ cfg.setCacheConfiguration(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
+ .setBackups(1)
+ .setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 60))));
+ }
+
+ cfg.setCommunicationSpi(new CheckingCommunicationSpi());
+
+ return cfg;
+ }
+
+ /** */
+ @Test
+ public void testScanQueryIteratorExpireEntriesFlush() throws Exception {
+ try (IgniteEx ignored = startGrids(2)) {
+ try (IgniteEx cln = startClientGrid(2)) {
+ for (int i = 0; i < KEYS; i++)
+ cln.cache(DEFAULT_CACHE_NAME).put(i, i);
+
+ cln.cache(DEFAULT_CACHE_NAME).query(new ScanQuery<>()).forEach((v) -> {});
+ }
+
+ grid(0).context().pools().getStripedExecutorService().awaitComplete();
+ grid(1).context().pools().getStripedExecutorService().awaitComplete();
+
+ assertTrue("Each key must be sent only once", CheckingCommunicationSpi.keyCnt.values().stream().allMatch(c -> c == 1));
+
+ assertTrue("Single GridCacheTtlUpdateRequest must be sent with no more then maximum allowed keys " +
+ "[maxAllowed=" + (EXPIRE_ENTRIES_FLUSH_CNT + 1) +
Review Comment:
Let's add comment why `EXPIRE_ENTRIES_FLUSH_CNT + 1` (`readyToFlush` method checks `entries.size() > EXPIRE_ENTRIES_FLUSH_CNT`)
##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/query/ScanQueryUpdateTtlTest.java:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.ignite.internal.processors.cache.query;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import javax.cache.expiry.Duration;
+import javax.cache.expiry.TouchedExpiryPolicy;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.TestRecordingCommunicationSpi;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
+import org.apache.ignite.internal.processors.cache.KeyCacheObject;
+import org.apache.ignite.internal.processors.cache.distributed.GridCacheTtlUpdateRequest;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+import org.junit.Test;
+
+import static org.apache.ignite.internal.processors.cache.query.ScanQueryIterator.EXPIRE_ENTRIES_FLUSH_CNT;
+
+/** */
+public class ScanQueryUpdateTtlTest extends GridCommonAbstractTest {
+ /** */
+ private static final int KEYS = EXPIRE_ENTRIES_FLUSH_CNT * 3;
+
+ /** {@inheritDoc} */
+ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
+ IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
+
+ if (!cfg.isClientMode()) {
+ cfg.setCacheConfiguration(new CacheConfiguration<>(DEFAULT_CACHE_NAME)
+ .setBackups(1)
+ .setExpiryPolicyFactory(TouchedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 60))));
+ }
+
+ cfg.setCommunicationSpi(new CheckingCommunicationSpi());
+
+ return cfg;
+ }
+
+ /** */
+ @Test
+ public void testScanQueryIteratorExpireEntriesFlush() throws Exception {
+ try (IgniteEx ignored = startGrids(2)) {
+ try (IgniteEx cln = startClientGrid(2)) {
+ for (int i = 0; i < KEYS; i++)
+ cln.cache(DEFAULT_CACHE_NAME).put(i, i);
+
+ cln.cache(DEFAULT_CACHE_NAME).query(new ScanQuery<>()).forEach((v) -> {});
+ }
+
+ grid(0).context().pools().getStripedExecutorService().awaitComplete();
+ grid(1).context().pools().getStripedExecutorService().awaitComplete();
+
+ assertTrue("Each key must be sent only once", CheckingCommunicationSpi.keyCnt.values().stream().allMatch(c -> c == 1));
+
+ assertTrue("Single GridCacheTtlUpdateRequest must be sent with no more then maximum allowed keys " +
+ "[maxAllowed=" + (EXPIRE_ENTRIES_FLUSH_CNT + 1) +
+ ", maxActual=" + CheckingCommunicationSpi.maxKeyBatchCnt + "]",
+ CheckingCommunicationSpi.maxKeyBatchCnt <= EXPIRE_ENTRIES_FLUSH_CNT + 1);
+
+ assertEquals("All keys must be sent", KEYS, CheckingCommunicationSpi.keyCnt.keySet().size());
+ }
+ }
+
+ /** */
+ private static class CheckingCommunicationSpi extends TestRecordingCommunicationSpi {
+ /** */
+ private static int maxKeyBatchCnt = 0;
+
+ /** */
+ private static Map<KeyCacheObject, Integer> keyCnt = new ConcurrentHashMap<>(KEYS);
Review Comment:
1. `private static final`
2. `new ConcurrentHashMap<>(U.capacity(KEYS))`
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] IGNITE-23971 Fix striped queue overflow in ScanQuery for caches with touched or accessed TTL expire policy [ignite]
Posted by "asfgit (via GitHub)" <gi...@apache.org>.
asfgit closed pull request #11736: IGNITE-23971 Fix striped queue overflow in ScanQuery for caches with touched or accessed TTL expire policy
URL: https://github.com/apache/ignite/pull/11736
--
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: notifications-unsubscribe@ignite.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org