-
Notifications
You must be signed in to change notification settings - Fork 30
fix(database)!: use transactions tied to repo counters for hook and build to avoid collisions #1353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
❌ Your project check has failed because the head coverage (58.36%) is below the target coverage (90.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1353 +/- ##
==========================================
+ Coverage 58.16% 58.36% +0.20%
==========================================
Files 646 645 -1
Lines 24931 24864 -67
==========================================
+ Hits 14500 14511 +11
+ Misses 9767 9681 -86
- Partials 664 672 +8
🚀 New features to boost your workflow:
|
wass3rw3rk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see below
| modReq := &ModifyRequest{ | ||
| Pipeline: string(data), | ||
| Build: apiBuild.GetNumber(), | ||
| Build: repo.GetCounter() + 1, // this is an assumption |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this introduce concurrency issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on what the modification endpoint does. I wasn't sure whether to remove the build number completely or make an assumption
I hesitate to say "fixes" for go-vela/community#997 and go-vela/community#213 because at very very high concurrency (300 simultaneous webhooks for one repo), it's still possible to see this issue I noticed. However, these changes can handle a great deal more concurrency compared to
main.In my testing, I was able to send 30+ webhooks simultaneously and 300+ with a .25 second delay and not run into duplicate key issues.
The key difference here is removing fetches for counters and instead tying the repo counters to the create functions for hooks and builds.
This PR also forces the worker's substitution routine to play a critical role in rendering any env vars containing the build number. This breaks situations in templates when teams use those specific Vela platform vars in a sprig func like
{{ vela "BUILD_NUMBER" }}This should really just be
${VELA_BUILD_NUMBER}, but if a user is — for whatever reason — performing some sort of inline Go logic based on build number, this would be a regression for them.