From 5ce2f5cb975e06565a65e2364adf90b65f2cf96e Mon Sep 17 00:00:00 2001 From: Alec Huang Date: Thu, 2 May 2024 15:48:37 -0700 Subject: [PATCH 1/4] add exception catch --- .../streaming/internal/FlushService.java | 49 ++++++++++++------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java index 5848cc10d..cd9fe431c 100644 --- a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java +++ b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java @@ -282,25 +282,36 @@ private void createWorkers() { this.flushWorker = Executors.newSingleThreadScheduledExecutor(flushThreadFactory); this.flushWorker.scheduleWithFixedDelay( () -> { - flush(false) - .exceptionally( - e -> { - String errorMessage = - String.format( - "Background flush task failed, client=%s, exception=%s, detail=%s," - + " trace=%s.", - this.owningClient.getName(), - e.getCause(), - e.getCause().getMessage(), - getStackTrace(e.getCause())); - logger.logError(errorMessage); - if (this.owningClient.getTelemetryService() != null) { - this.owningClient - .getTelemetryService() - .reportClientFailure(this.getClass().getSimpleName(), errorMessage); - } - return null; - }); + try { + flush(false) + .exceptionally( + e -> { + String errorMessage = + String.format( + "Background flush task failed, client=%s, exception=%s, detail=%s," + + " trace=%s.", + this.owningClient.getName(), + e.getCause(), + e.getCause().getMessage(), + getStackTrace(e.getCause())); + logger.logError(errorMessage); + if (this.owningClient.getTelemetryService() != null) { + this.owningClient + .getTelemetryService() + .reportClientFailure(this.getClass().getSimpleName(), errorMessage); + } + return null; + }); + } catch (Exception e) { + String errorMessage = + String.format( + "Failed to schedule a flush task, client=%s, exception=%s, detail=%s, trace=%s.", + this.owningClient.getName(), + e.getClass().getName(), + e.getMessage(), + getStackTrace(e)); + logger.logError(errorMessage); + } }, 0, this.owningClient.getParameterProvider().getBufferFlushCheckIntervalInMs(), From 7de35824a5eb63e5fbb9581074006bdf638d9c7f Mon Sep 17 00:00:00 2001 From: Alec Huang Date: Tue, 7 May 2024 17:07:03 -0400 Subject: [PATCH 2/4] Update format --- .../net/snowflake/ingest/streaming/internal/FlushService.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java index cd9fe431c..7eca40286 100644 --- a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java +++ b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java @@ -305,7 +305,8 @@ private void createWorkers() { } catch (Exception e) { String errorMessage = String.format( - "Failed to schedule a flush task, client=%s, exception=%s, detail=%s, trace=%s.", + "Failed to schedule a flush task, client=%s, exception=%s, detail=%s," + + " trace=%s.", this.owningClient.getName(), e.getClass().getName(), e.getMessage(), From 616afa5cea8ff7bea58f770aa3dd391da9d58701 Mon Sep 17 00:00:00 2001 From: Alec Huang Date: Mon, 13 May 2024 13:15:00 -0700 Subject: [PATCH 3/4] Add error log in telemetry. --- .../snowflake/ingest/streaming/internal/FlushService.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java index 7eca40286..69b2c629e 100644 --- a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java +++ b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java @@ -312,6 +312,11 @@ private void createWorkers() { e.getMessage(), getStackTrace(e)); logger.logError(errorMessage); + if (this.owningClient.getTelemetryService() != null) { + this.owningClient + .getTelemetryService() + .reportClientFailure(this.getClass().getSimpleName(), errorMessage); + } } }, 0, From fbe052548cc7f4b0aabbce86395562cbd8b50486 Mon Sep 17 00:00:00 2001 From: Alec Huang Date: Mon, 13 May 2024 14:39:41 -0700 Subject: [PATCH 4/4] Rethrow error. --- .../net/snowflake/ingest/streaming/internal/FlushService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java index 69b2c629e..f08196477 100644 --- a/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java +++ b/src/main/java/net/snowflake/ingest/streaming/internal/FlushService.java @@ -317,6 +317,7 @@ private void createWorkers() { .getTelemetryService() .reportClientFailure(this.getClass().getSimpleName(), errorMessage); } + throw e; } }, 0,