-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] reduce possibility for races in ResetUsage #15006
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
Conversation
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.
LGTM
/hold for improved log which can be used to correlate any future duplicates with logs
cc := &db.CostCenter{ | ||
ID: db.NewUserAttributionID(uuid.New().String()), | ||
CreationTime: db.NewVarCharTime(time.Now()), | ||
SpendingLimit: 500, | ||
BillingStrategy: db.CostCenter_Stripe, | ||
}) | ||
} | ||
|
||
err := conn.Save(cc).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.
You could use dbtest.CreateCostCenter
.
|
||
now := time.Now().UTC() | ||
|
||
logger.Info("Running `ResetUsage`.") |
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.
logger.Info("Running `ResetUsage`.") | |
logger.WithField("attribution_id", id).WithField("cost_center", cc).Infof("Resetting usage for Attribution ID %s", id) |
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.
👍 Added the cost center. the attributiond id was already included and I like to keep the message static, as it's a bit easier to filter on that way.
c486546
to
1d53a42
Compare
/unhold |
Description
Fetch the cost center from db immediately before deciding to resetting the usage. So that the time window in which a parallel resetting for the same cost center could happen is minimized.
We saw eight cases in Nopvember where thsi happened. But teh likely hood was very high due to:
Related Issue(s)
Fixes #14973
How to test
Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide
,jetbrains
,vscode
,ssh