frankgh commented on code in PR #205:
URL: https://github.com/apache/cassandra-sidecar/pull/205#discussion_r1996135149


##########
server/src/main/java/org/apache/cassandra/sidecar/datahub/SchemaReportingTask.java:
##########
@@ -94,17 +97,34 @@ public DurationSpec delay()
     }
 
     @Override
-    public void execute(Promise<Void> promise)
+    public void execute(@NotNull Promise<Void> promise)
+    {
+        execute(promise, 1);
+    }
+
+    protected void execute(@NotNull Promise<Void> promise,
+                           int attempt)
     {
         try
         {
+            LOGGER.info("Schema report has been triggered by the schedule");
             reporter.process(session.get().getCluster());

Review Comment:
   maybe a log entry indicating success as well after the reporting completes?



##########
server/src/main/java/org/apache/cassandra/sidecar/datahub/SchemaReportingTask.java:
##########
@@ -94,17 +97,34 @@ public DurationSpec delay()
     }
 
     @Override
-    public void execute(Promise<Void> promise)
+    public void execute(@NotNull Promise<Void> promise)
+    {
+        execute(promise, 1);
+    }
+
+    protected void execute(@NotNull Promise<Void> promise,
+                           int attempt)
     {
         try
         {
+            LOGGER.info("Schema report has been triggered by the schedule");
             reporter.process(session.get().getCluster());
             promise.complete();
         }
         catch (Throwable throwable)
         {
-            LOGGER.error("Failed to convert and report the current schema", 
throwable);
-            promise.fail(throwable);
+            if (attempt < configuration.retries())
+            {
+                LOGGER.warn("Schema report has failed and will be retried 
soon", throwable);

Review Comment:
   ```suggestion
                   LOGGER.warn("Schema report has failed and will be retried in 
{}", configuration.delay(), throwable);
   ```



##########
conf/sidecar.yaml:
##########
@@ -148,6 +148,7 @@ schema_reporting:                            # Schema 
Reporting configuration
   endpoint:         http://localhost/schema  # Endpoint address for schema 
reporting
   method:           PUT                      # HTTP verb to use for schema 
reporting
   retries:          3                        # Number of times a failing 
schema report is retried
+  delay:            1m                       # Delay before a failing schema 
report is retried

Review Comment:
   can we rename this to `retry_delay` for consistency with the existing retry 
delay configurations?



##########
server/src/main/java/org/apache/cassandra/sidecar/datahub/SchemaReportingTask.java:
##########
@@ -94,17 +97,34 @@ public DurationSpec delay()
     }
 
     @Override
-    public void execute(Promise<Void> promise)
+    public void execute(@NotNull Promise<Void> promise)
+    {
+        execute(promise, 1);
+    }
+
+    protected void execute(@NotNull Promise<Void> promise,
+                           int attempt)
     {
         try
         {
+            LOGGER.info("Schema report has been triggered by the schedule");
             reporter.process(session.get().getCluster());
             promise.complete();
         }
         catch (Throwable throwable)
         {
-            LOGGER.error("Failed to convert and report the current schema", 
throwable);
-            promise.fail(throwable);
+            if (attempt < configuration.retries())
+            {
+                LOGGER.warn("Schema report has failed and will be retried 
soon", throwable);
+                executor.setTimer(configuration.delay().toMillis(),
+                                  identifier -> execute(promise, attempt + 1));
+                // Retry will take care of either completing or failing the 
promise
+            }
+            else
+            {
+                LOGGER.error("Schema report is failing repeatedly and will not 
be retried", throwable);

Review Comment:
   ```suggestion
                   LOGGER.error("Schema report failed after {} retries and will 
not be retried", configuration.retries(), throwable);
   ```



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