From 4a0d2d2135023177419b26dd5dd9f05330224f14 Mon Sep 17 00:00:00 2001 From: Fabrizio Sestito Date: Wed, 26 Jan 2022 16:39:26 +0100 Subject: [PATCH 1/2] Remove skipping for an older event --- web/datapipeline/projector.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/web/datapipeline/projector.go b/web/datapipeline/projector.go index f822232dd..9ad23eb30 100644 --- a/web/datapipeline/projector.go +++ b/web/datapipeline/projector.go @@ -53,15 +53,6 @@ func (p *projector) Project(dataCollectedEvent *DataCollectedEvent) error { var subscription Subscription tx.Clauses(clause.Locking{Strength: "UPDATE"}).Where(&Subscription{ProjectorID: p.ID, AgentID: dataCollectedEvent.AgentID}).First(&subscription) - if subscription.LastProjectedEventID >= dataCollectedEvent.ID { - log.Warnf("Projector: %s received an old event: %s %s %d. Skipping", - p.ID, dataCollectedEvent.DiscoveryType, - dataCollectedEvent.AgentID, - dataCollectedEvent.ID) - - return nil - } - tx.Clauses(clause.OnConflict{ UpdateAll: true, }).Create(&Subscription{ From b5e1a6733608c3bfe57e557ec0d8ce5f4b11346e Mon Sep 17 00:00:00 2001 From: Fabrizio Sestito Date: Wed, 26 Jan 2022 16:57:35 +0100 Subject: [PATCH 2/2] Update tests --- web/datapipeline/projector_test.go | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/web/datapipeline/projector_test.go b/web/datapipeline/projector_test.go index 47b24d3e7..5f47158b3 100644 --- a/web/datapipeline/projector_test.go +++ b/web/datapipeline/projector_test.go @@ -114,29 +114,3 @@ func (suite *ProjectorTestSuite) TestProjector_Concurrency() { suite.Equal(int64(2), subscription.LastProjectedEventID) } - -// TestProjector_SkipPastEvent tests that a projector does not project and update the subscription -// if the event is older than the last projected one -func (suite *ProjectorTestSuite) TestProjector_SkipPastEvent() { - projector := NewProjector("dummy_projector", suite.tx) - projected := false - - projector.AddHandler("dummy_discovery_type", func(dataCollectedEvent *DataCollectedEvent, _ *gorm.DB) error { - projected = true - return nil - }) - - suite.tx.Create(&Subscription{ - LastProjectedEventID: 123, - ProjectorID: "dummy_projector", - AgentID: "345", - }) - - projector.Project(&DataCollectedEvent{ID: 120, DiscoveryType: "dummy_discovery_type", AgentID: "345"}) - - var subscription Subscription - suite.tx.First(&subscription) - - suite.False(projected) - suite.Equal(int64(123), subscription.LastProjectedEventID) -}