-
Notifications
You must be signed in to change notification settings - Fork 887
feat: expose Everyone group through UI #9117
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
2c7b98d
feat: allow setting quotas on Everyone group
sreya 5a53863
lint
sreya 1d77ffa
pr comments
sreya f6cf3b7
break
sreya 59db543
port ReadModifyUpdate
sreya e2da043
redundant check
sreya 3708a4c
pr comments
sreya 13b8689
fix a test
sreya 48b2e3f
lint
sreya 12a6112
fmt
sreya c6bd4db
gen
sreya 572674b
fix tests
sreya dddb9ea
fix another test
sreya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package database | ||
|
||
import ( | ||
"database/sql" | ||
|
||
"github.com/lib/pq" | ||
"golang.org/x/xerrors" | ||
) | ||
|
||
const maxRetries = 5 | ||
|
||
// ReadModifyUpdate is a helper function to run a db transaction that reads some | ||
// object(s), modifies some of the data, and writes the modified object(s) back | ||
// to the database. It is run in a transaction at RepeatableRead isolation so | ||
// that if another database client also modifies the data we are writing and | ||
// commits, then the transaction is rolled back and restarted. | ||
// | ||
// This is needed because we typically read all object columns, modify some | ||
// subset, and then write all columns. Consider an object with columns A, B and | ||
// initial values A=1, B=1. Two database clients work simultaneously, with one | ||
// client attempting to set A=2, and another attempting to set B=2. They both | ||
// initially read A=1, B=1, and then one writes A=2, B=1, and the other writes | ||
// A=1, B=2. With default PostgreSQL isolation of ReadCommitted, both of these | ||
// transactions would succeed and we end up with either A=2, B=1 or A=1, B=2. | ||
// One or other client gets their transaction wiped out even though the data | ||
// they wanted to change didn't conflict. | ||
// | ||
// If we run at RepeatableRead isolation, then one or other transaction will | ||
// fail. Let's say the transaction that sets A=2 succeeds. Then the first B=2 | ||
// transaction fails, but here we retry. The second attempt we read A=2, B=1, | ||
// then write A=2, B=2 as desired, and this succeeds. | ||
func ReadModifyUpdate(db Store, f func(tx Store) error, | ||
) error { | ||
var err error | ||
for retries := 0; retries < maxRetries; retries++ { | ||
err = db.InTx(f, &sql.TxOptions{ | ||
Isolation: sql.LevelRepeatableRead, | ||
}) | ||
var pqe *pq.Error | ||
if xerrors.As(err, &pqe) { | ||
if pqe.Code == "40001" { | ||
// serialization error, retry | ||
continue | ||
} | ||
} | ||
return err | ||
} | ||
return xerrors.Errorf("too many errors; last error: %w", err) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Curious about the decision to not use retry logic and spin. Is there a thundering herd risk?
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.
Inspired by this function, I added
Jitter
to our retry package: https://pkg.go.dev/github.com/coder/retry#Retrier.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.
Honestly I just copied this from v1. In the interest of getting this PR merged I'd like to leave it as-is.
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.
sure thing, didn't know that