forked from cerc-io/ipld-eth-server
Queue storage diffs if transformer execution fails
- For any error, not just if key isn't recognized - Means we don't lose track of diffs on random ephemeral errors
This commit is contained in:
parent
76ab914bdc
commit
b036053937
@ -79,13 +79,10 @@ func (storageWatcher StorageWatcher) processRow(row utils.StorageDiffRow) {
|
|||||||
}
|
}
|
||||||
executeErr := storageTransformer.Execute(row)
|
executeErr := storageTransformer.Execute(row)
|
||||||
if executeErr != nil {
|
if executeErr != nil {
|
||||||
if isKeyNotFound(executeErr) {
|
logrus.Warn(fmt.Sprintf("error executing storage transformer: %s", executeErr))
|
||||||
queueErr := storageWatcher.Queue.Add(row)
|
queueErr := storageWatcher.Queue.Add(row)
|
||||||
if queueErr != nil {
|
if queueErr != nil {
|
||||||
logrus.Warn(fmt.Sprintf("error queueing storage diff with unrecognized key: %s", queueErr))
|
logrus.Warn(fmt.Sprintf("error queueing storage diff: %s", queueErr))
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logrus.Warn(fmt.Sprintf("error executing storage transformer: %s", executeErr))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,8 +109,8 @@ var _ = Describe("Storage Watcher", func() {
|
|||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("queues row for later processing if row's key not recognized", func(done Done) {
|
It("queues row for later processing if transformer execution fails", func(done Done) {
|
||||||
mockTransformer.ExecuteErr = utils.ErrStorageKeyNotFound{}
|
mockTransformer.ExecuteErr = fakes.FakeError
|
||||||
|
|
||||||
go storageWatcher.Execute(rows, errs, time.Hour)
|
go storageWatcher.Execute(rows, errs, time.Hour)
|
||||||
|
|
||||||
@ -143,22 +143,6 @@ var _ = Describe("Storage Watcher", func() {
|
|||||||
}).Should(ContainSubstring(fakes.FakeError.Error()))
|
}).Should(ContainSubstring(fakes.FakeError.Error()))
|
||||||
close(done)
|
close(done)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("logs error if transformer execution fails for reason other than key not found", func(done Done) {
|
|
||||||
mockTransformer.ExecuteErr = fakes.FakeError
|
|
||||||
tempFile, fileErr := ioutil.TempFile("", "log")
|
|
||||||
Expect(fileErr).NotTo(HaveOccurred())
|
|
||||||
defer os.Remove(tempFile.Name())
|
|
||||||
logrus.SetOutput(tempFile)
|
|
||||||
|
|
||||||
go storageWatcher.Execute(rows, errs, time.Hour)
|
|
||||||
|
|
||||||
Eventually(func() (string, error) {
|
|
||||||
logContent, err := ioutil.ReadFile(tempFile.Name())
|
|
||||||
return string(logContent), err
|
|
||||||
}).Should(ContainSubstring(fakes.FakeError.Error()))
|
|
||||||
close(done)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("transforming queued storage diffs", func() {
|
Describe("transforming queued storage diffs", func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user