-
Notifications
You must be signed in to change notification settings - Fork 151
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
NEOS-1774: Adds dropping and updating triggers to Mysql Init Schema #3382
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3382 +/- ##
==========================================
- Coverage 24.22% 24.18% -0.04%
==========================================
Files 414 414
Lines 48340 48366 +26
==========================================
- Hits 11711 11699 -12
- Misses 35508 35550 +42
+ Partials 1121 1117 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Benchstat Geomean Results0.39% sec/op, -0.03% B/op, 0.97% allocs/op Benchstat results
|
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.
overall lgtm, let some minor comments regarding concurrent syncs
@@ -114,6 +116,20 @@ func getDatabaseDataForSchemaDiff( | |||
return nil | |||
}) | |||
|
|||
trigmu := sync.Mutex{} | |||
errgrp.Go(func() error { |
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.
is this running in a loop or is anything else other than this goroutine writing to the triggers slice?? if not I think the mutex is not needed.
return fmt.Errorf("failed to retrieve database table triggers: %w", err) | ||
} | ||
for _, tabletrigger := range tabletriggers { | ||
trigmu.Lock() |
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.
if the mutex is actually needed, it might be better to just lock it before the for loop and then defer unlock right after. let the for loop hydrate the map and then exit, unlocking the mutex.
mu.Unlock() | ||
for _, tableconstraint := range tableconstraints { | ||
for _, nonFkConstraint := range tableconstraint.NonForeignKeyConstraints { | ||
mu.Lock() |
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.
same Q's here. idk if the mutex is needed unless more than one thing in a different goroutine is writing to this map.
If it is needed, it's excessive to lock/unlock within this for loop I think. especially given you are just overwriting the map contents and not checking if there is a collision.
No description provided.