Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-19532

Introduce happends before relation between local meta storage safe time publication and completion of corresponding meta storage listners

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Blocker
    • Resolution: Fixed
    • None
    • 3.0
    • None

    Description

      Motivation

      Let's assume that we have a component named LeaseTracker that locally stores leases in a map though meta storage updates

      public class LeaseTracker implements PlacementDriver {
      /** Leases cache. */
      private final Map<ReplicationGroupId, Lease> leases; 
      ...
      
          private class UpdateListener implements WatchListener {
              @Override
              public CompletableFuture<Void> onUpdate(WatchEvent event) {
                  for (EntryEvent entry : event.entryEvents()) {
                           ...
                          Lease lease = fromBytes(msEntry.value());
                          leases.put(grpId, lease);
                          ...
                  return completedFuture(null);
              }
          }
      ...

      and we want to await lease in a meta storage safe time bounded way.

      public CompletableFuture<LeaseMeta> getPrimaryReplica(ReplicationGroupId replicationGroupId, HybridTimestamp timestamp) {
      ...
      
              return msManager.clusterTime().waitFor(timestamp).thenApply(() -> {
                          ...
                          Lease lease0 = leases.get(replicationGroupId);
      
                          if (lease.getExpirationTime().after(timestamp)) {
                              return lease0;
                          } else {
                              return null;
                          }
                          ...
             }
      } 

      Currently that won't work properly

      because 

      msManager.clusterTime().waitFor(timestamp) 

      will be completed before local leases will be populated with data through meta storage events.

      Thus it'll be nice to complete clusterTime().waitFor(timestamp) futute (and generally speaking publish safe time) after all corresponding ms listeners are completed.

      Attachments

        Issue Links

          Activity

            People

              sdanilov Semyon Danilov
              alapin Alexander Lapin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m