krummas commented on code in PR #3458:
URL: https://github.com/apache/cassandra/pull/3458#discussion_r1709613518


##########
src/java/org/apache/cassandra/schema/DistributedMetadataLogKeyspace.java:
##########
@@ -161,6 +161,11 @@ public static LogState getLogState(Epoch since, boolean 
consistentFetch)
         return (consistentFetch ? serialLogReader : 
localLogReader).getLogState(since);
     }
 
+    public static LogState getLogState(Epoch start, Epoch end, boolean 
consistentFetch)

Review Comment:
   consistentFetch is always true, can remove the parameter



##########
src/java/org/apache/cassandra/tcm/RemoteProcessor.java:
##########
@@ -148,6 +148,30 @@ public ClusterMetadata fetchLogAndWait(Epoch waitFor, 
Retry.Deadline retryPolicy
         }
     }
 
+    @Override
+    public LogState reconstruct(Epoch lowEpoch, Epoch highEpoch, 
Retry.Deadline retryPolicy)
+    {
+        try
+        {
+            Promise<LogState> request = new AsyncPromise<>();
+            List<InetAddressAndPort> candidates = new 
ArrayList<>(log.metadata().fullCMSMembers());
+            sendWithCallbackAsync(request,

Review Comment:
   should we debounce this?



##########
src/java/org/apache/cassandra/tcm/RemoteProcessor.java:
##########
@@ -148,6 +148,30 @@ public ClusterMetadata fetchLogAndWait(Epoch waitFor, 
Retry.Deadline retryPolicy
         }
     }
 
+    @Override
+    public LogState reconstruct(Epoch lowEpoch, Epoch highEpoch, 
Retry.Deadline retryPolicy)
+    {
+        try
+        {
+            Promise<LogState> request = new AsyncPromise<>();
+            List<InetAddressAndPort> candidates = new 
ArrayList<>(log.metadata().fullCMSMembers());
+            sendWithCallbackAsync(request,
+                                  Verb.TCM_RECONSTRUCT_EPOCH_REQ,
+                                  new ReconstructLogState(lowEpoch, highEpoch),
+                                  new CandidateIterator(candidates),
+                                  new 
Retry.Backoff(TCMMetrics.instance.fetchLogRetries));
+            return request.get(retryPolicy.remainingNanos(), 
TimeUnit.NANOSECONDS);

Review Comment:
   Should we store the returned LogState in the local tables?



##########
src/java/org/apache/cassandra/tcm/log/LogReader.java:
##########
@@ -110,6 +112,54 @@ default LogState getLogState(Epoch startEpoch)
         }
     }
 
+    default LogState getLogState(Epoch start, Epoch end)

Review Comment:
   should probably override this method in `NoOpLogStorage`



##########
src/java/org/apache/cassandra/tcm/log/LogReader.java:
##########
@@ -110,6 +112,54 @@ default LogState getLogState(Epoch startEpoch)
         }
     }
 
+    default LogState getLogState(Epoch start, Epoch end)
+    {
+        try
+        {
+            ClusterMetadata closestSnapshot = 
snapshots().getSnapshotBefore(start);
+
+            // Snapshot could not be found, fetch enough epochs to reconstruct 
the start metadata
+            if (closestSnapshot == null)
+            {
+                closestSnapshot = new 
ClusterMetadata(DatabaseDescriptor.getPartitioner());
+                ImmutableList.Builder<Entry> entries = new 
ImmutableList.Builder<>();
+                EntryHolder entryHolder = getEntries(Epoch.EMPTY, end);
+                for (Entry entry : entryHolder.entries)
+                {
+                    if (entry.epoch.isAfter(start))
+                        entries.add(entry);
+                    else
+                        closestSnapshot = 
entry.transform.execute(closestSnapshot).success().metadata;
+                }
+                return new LogState(closestSnapshot, entries.build());
+            }
+            else if (closestSnapshot.epoch.isBefore(start))
+            {
+                ImmutableList.Builder<Entry> entries = new 
ImmutableList.Builder<>();
+                // TODO (required): EntryHolder#add seems not to play along 
with the low epoch bound.

Review Comment:
   is this todo still needed?



##########
src/java/org/apache/cassandra/tcm/log/LogReader.java:
##########
@@ -110,6 +112,54 @@ default LogState getLogState(Epoch startEpoch)
         }
     }
 
+    default LogState getLogState(Epoch start, Epoch end)

Review Comment:
   Should there be a way for this to not return a snapshot (they can get fairly 
large)? I'm thinking of a situation when reconstructing the log due to gaps in 
the log, then we could just reconstruct from the current local epoch, with no 
need to get a snapshot from the CMS



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to