From a3a58a757dbc367029344b9bf326349ec18513ff Mon Sep 17 00:00:00 2001 From: Priyanshi Gupta Date: Thu, 6 Mar 2025 13:08:21 +0530 Subject: [PATCH] Fix: nil pointer exception while sending the callhome payload for import data to source/source-replica (#2371) Fixing the nil pointer exception while sending the call home payload for exit/error case during initial phase of import data to source/source-replica. fixes #2364 --- yb-voyager/cmd/importDataToSource.go | 6 ++++-- yb-voyager/cmd/importDataToSourceReplica.go | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/yb-voyager/cmd/importDataToSource.go b/yb-voyager/cmd/importDataToSource.go index fc27566953..91214f33ab 100644 --- a/yb-voyager/cmd/importDataToSource.go +++ b/yb-voyager/cmd/importDataToSource.go @@ -98,7 +98,9 @@ func packAndSendImportDataToSourcePayload(status string, errorMsg string) { sourceDBDetails := callhome.SourceDBDetails{ DBType: tconf.TargetDBType, - DBVersion: targetDBDetails.DBVersion, + } + if targetDBDetails != nil { + sourceDBDetails.DBVersion = targetDBDetails.DBVersion } payload.SourceDBDetails = callhome.MarshalledJsonString(sourceDBDetails) @@ -112,7 +114,7 @@ func packAndSendImportDataToSourcePayload(status string, errorMsg string) { importDataPayload.Phase = importPhase - if importPhase != dbzm.MODE_SNAPSHOT { + if importPhase != dbzm.MODE_SNAPSHOT && statsReporter != nil { importDataPayload.EventsImportRate = statsReporter.EventsImportRateLast3Min importDataPayload.TotalImportedEvents = statsReporter.TotalEventsImported } diff --git a/yb-voyager/cmd/importDataToSourceReplica.go b/yb-voyager/cmd/importDataToSourceReplica.go index f8e93ac236..2a0402b84f 100644 --- a/yb-voyager/cmd/importDataToSourceReplica.go +++ b/yb-voyager/cmd/importDataToSourceReplica.go @@ -100,9 +100,11 @@ func packAndSendImportDataToSrcReplicaPayload(status string, errorMsg string) { payload.MigrationType = LIVE_MIGRATION sourceDBDetails := callhome.SourceDBDetails{ - DBType: tconf.TargetDBType, - DBVersion: targetDBDetails.DBVersion, - Role: "replica", + DBType: tconf.TargetDBType, + Role: "replica", + } + if targetDBDetails != nil { + sourceDBDetails.DBVersion = targetDBDetails.DBVersion } payload.SourceDBDetails = callhome.MarshalledJsonString(sourceDBDetails) @@ -128,7 +130,7 @@ func packAndSendImportDataToSrcReplicaPayload(status string, errorMsg string) { importDataPayload.Phase = importPhase - if importPhase != dbzm.MODE_SNAPSHOT { + if importPhase != dbzm.MODE_SNAPSHOT && statsReporter != nil { importDataPayload.EventsImportRate = statsReporter.EventsImportRateLast3Min importDataPayload.TotalImportedEvents = statsReporter.TotalEventsImported }