sanpwc commented on code in PR #2078:
URL: https://github.com/apache/ignite-3/pull/2078#discussion_r1199111998
##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/leases/LeaseTracker.java:
##########
@@ -152,4 +195,46 @@ public CompletableFuture<Void> onUpdate(WatchEvent event) {
public void onError(Throwable e) {
}
}
+
+ @Override
+ public CompletableFuture<LeaseMeta> awaitPrimaryReplica(ReplicationGroupId
groupId, HybridTimestamp timestamp) {
+ if (!busyLock.enterBusy()) {
+ return failedFuture(new NodeStoppingException("Component is
stopping."));
+ }
+ try {
+ return primaryReplicaWaiters.computeIfAbsent(groupId, id -> new
PendingIndependentComparableValuesTracker<>(MIN_VALUE))
+ .waitFor(timestamp);
+ } finally {
+ busyLock.leaveBusy();
+ }
+ }
+
+ @Override
+ public CompletableFuture<LeaseMeta> getPrimaryReplica(ReplicationGroupId
replicationGroupId, HybridTimestamp timestamp) {
+ if (!busyLock.enterBusy()) {
+ return failedFuture(new NodeStoppingException("Component is
stopping."));
+ }
+ try {
+ // There's no sense in awaiting previously detected primary
replica more than lease interval.
+ return awaitPrimaryReplica(replicationGroupId,
timestamp).orTimeout(longLeaseInterval, TimeUnit.MILLISECONDS);
Review Comment:
> Timeout transaction is possible to use here
Nope
> To use safe time is absolutely correct
Yes. I've reworked getPrimaryReplica to use the safe time. And created a
ticket in order to fix the race in meta storage safe time publication
https://issues.apache.org/jira/browse/IGNITE-19532 @SammyVimes is notified and
hopefully will fix it within next week. It worth to mention that I've run
corresponding test 1000 times - no failures, so I event didn't mute it with the
issue.
--
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]