Skip to content

fix: Recover panic in table resolver and object resolver flows#257

Merged
kodiakhq[bot] merged 7 commits intomainfrom
fix/recover
Oct 7, 2022
Merged

fix: Recover panic in table resolver and object resolver flows#257
kodiakhq[bot] merged 7 commits intomainfrom
fix/recover

Conversation

@yevgenypats
Copy link
Copy Markdown
Contributor

This also adds quite needed tests for our scheduler

This also adds quite needed tests for our scheduler
@github-actions github-actions bot added the fix label Oct 7, 2022
@yevgenypats yevgenypats changed the title fix: recover panic in table resolver and object resolver flows fix: Recover panic in table resolver and object resolver flows Oct 7, 2022
@github-actions github-actions bot added fix and removed fix labels Oct 7, 2022
Comment on lines +229 to +234
if tc.Summary.Resources != i {
t.Errorf("expected %d resources, got %d", tc.Summary.Resources, i)
}
if tc.Summary.Resources != summary.Resources {
t.Errorf("expected %d summary resources, got %d", tc.Summary.Resources, summary.Resources)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Looks like the second comparison here can never fail except if either: the case above it already failed, or the test is set up incorrectly. I'd probably remove the != i check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can (It did and this is why I've added it :) ) because the first check checks how many resources were returned on the channel and the second one just checks the statistics struct

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see now, sorry yeah. It's because it's written in want != got instead of got != want order that I misread it. My nit would then be to change the ordering :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is usually expected != got but also sometimes it's hard to keep the order consistent because for example you can't do 1 != some_var so you still have constraints.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Go it's usually got != expected, so that it's consistent when you have a constant got != 1 as well. https://github.com/golang/go/wiki/CodeReviewComments#useful-test-failures

Copy link
Copy Markdown
Contributor

@hermanschaaf hermanschaaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like the tests. LGTM 👍

sentry.WithScope(func(scope *sentry.Scope) {
scope.SetTag("table", t.Name)
sentry.CurrentHub().Recover(err)
sentry.CurrentHub().CaptureMessage(stack)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sentry should already include the stack trace?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

their logic is incorrect it doesn't print it in the right way and try to do some "smart things" - just a string of the stack trace should work for us I think.

@yevgenypats
Copy link
Copy Markdown
Contributor Author

@disq @hermanschaaf can you please take a look at the lint error - https://github.com/cloudquery/plugin-sdk/actions/runs/3203350691/jobs/5233341574#step:4:26

I think it's a false positive but just want to be sure before I ignore it.

@disq
Copy link
Copy Markdown
Member

disq commented Oct 7, 2022

I think it's a false positive but just want to be sure before I ignore it.

@yevgenypats I don't see how it can be a datarace, as we close res in the goroutine itself, so range res can't stop before resolving finishes.

@yevgenypats
Copy link
Copy Markdown
Contributor Author

That's right. I think it is a false positive because the linter doesn't detect that Im using atomic ?

@disq
Copy link
Copy Markdown
Member

disq commented Oct 7, 2022

That's right. I think it is a false positive because the linter doesn't detect that Im using atomic ?

atomic is unrelated in this error, it can still be a datarace if the goroutine doesn't finish before the function returns. But it does.

@hermanschaaf
Copy link
Copy Markdown
Contributor

hermanschaaf commented Oct 7, 2022

@yevgenypats I'm not 100% sure it is a data race either, but rather than ignore the warning, let's pass in a pointer to the goroutine so that it's definitely safe?

go func(syncSummary *SyncSummary) {
...
atomic.AddUint64(&syncSummary.Panics, 1)
...
atomic.AddUint64(&syncSummary.Errors, 1)
...
}(&summary)

@yevgenypats
Copy link
Copy Markdown
Contributor Author

good idea. done.

@kodiakhq kodiakhq bot merged commit 04dba02 into main Oct 7, 2022
@kodiakhq kodiakhq bot deleted the fix/recover branch October 7, 2022 08:50
meta.Logger().Trace().Str("table", t.Name).Msg("post resource resolver finished successfully")
}
}
summary.Resources = 1
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
summary.Resources = 1
summary.Resources++

kodiakhq bot pushed a commit that referenced this pull request Oct 7, 2022
🤖 I have created a release *beep* *boop*
---


## [0.12.8](v0.12.7...v0.12.8) (2022-10-07)


### Bug Fixes

* Error on incorrect table configuration ([#237](#237)) ([6ad75f5](6ad75f5))
* Exit gracefully on context cancelled ([#252](#252)) ([b4df92e](b4df92e))
* Progressbar should go into stdout ([#250](#250)) ([b8bcdad](b8bcdad))
* Recover panic in table resolver and object resolver flows ([#257](#257)) ([04dba02](04dba02))
* Stop if PreResourceResolver fails ([#251](#251)) ([ee83f8f](ee83f8f))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants