denis-chudov commented on code in PR #2003:
URL: https://github.com/apache/ignite-3/pull/2003#discussion_r1183022554
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -395,4 +407,54 @@ private boolean isLeaseOutdated(Lease lease) {
return now.after(lease.getExpirationTime());
}
}
+
+ /**
+ * Message handler to process notification from replica side.
+ */
+ private class PlacementDriverActorMessageHandler implements
NetworkMessageHandler {
+ @Override
+ public void onReceived(NetworkMessage msg0, String sender, @Nullable
Long correlationId) {
+ if (!(msg0 instanceof PlacementDriverActorMessage)) {
+ return;
+ }
+
+ var msg = (PlacementDriverActorMessage) msg0;
+
+ if (!stateActorLock.enterBusy()) {
+ return;
+ }
+
+ try {
+ processMessageInternal(sender, msg);
+ } finally {
+ stateActorLock.leaveBusy();
+ }
+ }
+
+ /**
+ * Processes an placement driver actor message. The method should be
invoked under state lock.
+ *
+ * @param sender Sender node name.
+ * @param msg Message.
+ */
+ private void processMessageInternal(String sender,
PlacementDriverActorMessage msg) {
+ ReplicationGroupId grpId = msg.groupId();
+
+ Lease lease = leaseTracker.getLease(grpId);
+
+ if (msg instanceof StopLeaseProlongationMessage) {
+ if (lease.isProlong() &&
sender.equals(lease.getLeaseholder().name())) {
Review Comment:
maybe rename this method to `isProlongable`?
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -395,4 +407,54 @@ private boolean isLeaseOutdated(Lease lease) {
return now.after(lease.getExpirationTime());
}
}
+
+ /**
+ * Message handler to process notification from replica side.
+ */
+ private class PlacementDriverActorMessageHandler implements
NetworkMessageHandler {
+ @Override
+ public void onReceived(NetworkMessage msg0, String sender, @Nullable
Long correlationId) {
+ if (!(msg0 instanceof PlacementDriverActorMessage)) {
+ return;
+ }
+
+ var msg = (PlacementDriverActorMessage) msg0;
+
+ if (!stateActorLock.enterBusy()) {
+ return;
+ }
+
Review Comment:
So we just throw this message away if this is not an active actor? Imagine
following:
- active actor crashes
- PD group leader election is in progress
- some group grp0 loses majority and wants to notify PD about this
- every known PD node throws away the message
- PD elects leader fast enough, so the lease for grp0 is not outdated and
the same leaseholder is chosen.
So the lease would be prolonged as if nothing happened, right?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]