Skip to content

Commit

Permalink
Make AddIndexBackupOperation allowed in passive state [HZ-4582] [HZ-4…
Browse files Browse the repository at this point in the history
…572] (#1076)

`AddIndexBackupOperation` should be allowed in passive state for the
same reason why `AddIndexOperation` is.

The issue became visible after improving assertions in
https://github.com/hazelcast/hazelcast-mono/pull/1009, before it just
failed (with warnings in logs) during proxy initialisation. This is a
missing part of https://github.com/hazelcast/hazelcast-mono/pull/596.

This PR fixes useless warnings `java.lang.IllegalStateException: Cluster
is in PASSIVE state! Operation:
com.hazelcast.map.impl.operation.AddIndexBackupOperation`. Map proxy
initialization on primary does not fail - backup operation errors are
ignored, so indexes should be fine. The only cases where it might matter
are:

1. for nodes that do not own any partitions but that is very unlikely
(see comment in `AddIndexBackupOperation.runInternal`).
2. if the members are restarted quickly one after another. Backup
operation has 5s timeout and in case of backup operation error no
response is returned. This may cause MapProxy not being initialized yet
when another member joins, so it will not be sent in
`PostJoinProxyOperation`.

There is a discrepancy in handling `Backup` which contains
not-`AllowedDuringPassiveState` operation in PASSIVE state between
normal execution (allowed! - does not check nested operation) and
offloaded execution (fails with `IllegalStateException` - steps engine
checks preconditions for nested operation). That explains the difference
between force-offload and normal behavior. This might be fixed
separately as it is error prone, but generally our operations should be
reasonably defined and not cause problems.

Fixes HZ-4582, HZ-4572
Fixes https://github.com/hazelcast/hazelcast-enterprise/issues/7076
Fixes https://github.com/hazelcast/hazelcast-enterprise/issues/7075

GitOrigin-RevId: ef1eec30f3a78f07c0c1e38ae6fbffb482a6a9f4
  • Loading branch information
k-jamroz authored and actions-user committed Mar 14, 2024
1 parent 6bb1da2 commit 5fadfb7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
import com.hazelcast.nio.ObjectDataInput;
import com.hazelcast.nio.ObjectDataOutput;
import com.hazelcast.query.impl.IndexRegistry;
import com.hazelcast.spi.impl.AllowedDuringPassiveState;
import com.hazelcast.spi.impl.operationservice.BackupOperation;

import java.io.IOException;

public class AddIndexBackupOperation extends MapOperation implements BackupOperation {
public class AddIndexBackupOperation extends MapOperation implements BackupOperation,
// AddIndexBackupOperation is used when map proxy for IMap with indexes is initialized during passive state
// (eg. IMap is read for the first time after HotRestart recovery when the cluster is still in PASSIVE state)
AllowedDuringPassiveState {

private IndexConfig config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,6 @@ public void ensureNodeAndClusterHealth(Operation op) {
* @param op the operation to execute
* @param startNanos the time, as returned by {@link System#nanoTime} when this operation
* started execution
* @return {@code true} if this operation was not executed and should be retried at a later time,
* {@code false} if the operation should not be retried, either because it
* timed out or has run successfully
*/
protected void run(Operation op, long startNanos) {
executedOperationsCounter.inc();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,14 @@ private void restartCluster(boolean graceful, ClusterState restartInState, Strin
warmUpPartitions(member1, member2);
member1.getCluster().changeClusterState(restartInState);
member1 = restartMember(member1, member2, graceful);

// do not restart the other member until proxy is fully initialized on first member
// so the proxy can be included in PostJoinProxyOperation. Proxy initialization may take
// some time (especially when backup operations fail) and is async process.
assertMapProxyInitializedEventually(indexMapName);

member2 = restartMember(member2, member1, graceful);

member1.getCluster().changeClusterState(ClusterState.ACTIVE);

// Wait for proxy initialization by post join operation to avoid race condition.
Expand Down

0 comments on commit 5fadfb7

Please sign in to comment.