From 77dc11a658a72bc558eed9af93603016657648d4 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 13 Apr 2024 21:45:24 +0100 Subject: [PATCH] Add additional logging to identify why CIF updates were sometimes failing --- cif/process.go | 5 +++++ dbAccess/cif.go | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/cif/process.go b/cif/process.go index d5bd2ec..38d63bf 100644 --- a/cif/process.go +++ b/cif/process.go @@ -68,6 +68,11 @@ func processParsedCif(data *parsedData) error { // Create delete query types and pass to the function which batches the deletions func doDeletions(deletions []*upstreamApi.JsonScheduleV1) error { + defer func() { + if r := recover(); r != nil { + log.Msg.Panic("Panic:", zap.Any("panic", r)) + } + }() deleteQueries := make([]database.DeleteQuery, 0) for _, item := range deletions { query := database.DeleteQuery{ diff --git a/dbAccess/cif.go b/dbAccess/cif.go index fafb0c2..735ff6d 100644 --- a/dbAccess/cif.go +++ b/dbAccess/cif.go @@ -74,11 +74,17 @@ func PutCifMetadata(metadata *CifMetadata, lastUpdateType string) bool { // Handles 'Delete' tasks from CIF Schedule updates, accepts DeleteQuery types and batches deletions. func DeleteCifEntries(deletions []database.DeleteQuery) error { + defer func() { + if r := recover(); r != nil { + log.Msg.Panic("Panic:", zap.Any("panic", r)) + } + }() // Skip if deletions is empty if len(deletions) == 0 { log.Msg.Info("No deletions required") return nil } + log.Msg.Info("Running deletions against database", zap.Int("count", len(deletions))) // Prepare deletion tasks collection := MongoClient.Database(databaseName).Collection(timetableCollection) @@ -111,6 +117,7 @@ func CreateCifEntries(schedules []database.Service) error { log.Msg.Info("No creations required") return nil } + log.Msg.Info("Running creations against database", zap.Int("count", len(schedules))) collection := MongoClient.Database(databaseName).Collection(timetableCollection)