ivanzlenko commented on code in PR #5101: URL: https://github.com/apache/ignite-3/pull/5101#discussion_r1928338998
########## modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/time/ClusterTimeImpl.java: ########## @@ -91,13 +100,17 @@ public ClusterTimeImpl(String nodeName, IgniteSpinBusyLock busyLock, HybridClock * * @param syncTimeAction Action that performs the time sync operation. */ - public void startSafeTimeScheduler(SyncTimeAction syncTimeAction, MetaStorageConfiguration configuration) { + public void startSafeTimeScheduler(SyncTimeAction syncTimeAction, MetaStorageConfiguration configuration, long term) { if (!busyLock.enterBusy()) { return; } try { synchronized (this) { + if (lastSchedulerStoppedTerm > term) { Review Comment: This is NullPointerException candidate. You can't see it in test because stopSafeTimeScheduler will be called before startSafeTimeScheduler and will initialize lastSchedulerStoppedTerm variable. ########## modules/metastorage/src/test/java/org/apache/ignite/internal/metastorage/impl/MetaStorageLeaderElectionListenerTest.java: ########## @@ -0,0 +1,102 @@ +/* + * 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.metastorage.impl; + +import static java.util.concurrent.CompletableFuture.completedFuture; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.List; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologyService; +import org.apache.ignite.internal.configuration.testframework.ConfigurationExtension; +import org.apache.ignite.internal.configuration.testframework.InjectConfiguration; +import org.apache.ignite.internal.hlc.HybridClockImpl; +import org.apache.ignite.internal.metastorage.configuration.MetaStorageConfiguration; +import org.apache.ignite.internal.metastorage.server.time.ClusterTimeImpl; +import org.apache.ignite.internal.network.ClusterNodeImpl; +import org.apache.ignite.internal.network.ClusterService; +import org.apache.ignite.internal.testframework.BaseIgniteAbstractTest; +import org.apache.ignite.internal.util.IgniteSpinBusyLock; +import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.network.NetworkAddress; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +@ExtendWith(ConfigurationExtension.class) +class MetaStorageLeaderElectionListenerTest extends BaseIgniteAbstractTest { + private static final String NODE_NAME = "foo"; + + @InjectConfiguration + private MetaStorageConfiguration metaStorageConfiguration; + + @Test + void testSafeTimeSchedulerNotCreatedAfterStoppedTerm() { Review Comment: We need to verify that clusterTime methods called correctly at least. Right now it is not clear what this test actually doing. Also would be nice to have javaDoc describing this 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org