Skip to content
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

remove lock #13

Merged
merged 1 commit into from
Oct 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions webapp/go/src/isucon8/isucoin/model/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func getOpenOrderByID(tx *sql.Tx, id int64) (*Order, error) {
if order.ClosedAt != nil {
return nil, ErrOrderAlreadyClosed
}
order.User, err = getUserByIDWithLock(tx, order.UserID)
order.User, err = GetUserByID(tx, order.UserID)
if err != nil {
return nil, errors.Wrap(err, "getUserByIDWithLock sell user")
}
Expand Down Expand Up @@ -85,11 +85,12 @@ func AddOrder(tx *sql.Tx, ot string, userID, amount, price int64) (*Order, error
if amount <= 0 || price <= 0 {
return nil, ErrParameterInvalid
}
user, err := getUserByIDWithLock(tx, userID)
user, err := GetUserByID(tx, userID)
if err != nil {
return nil, errors.Wrapf(err, "getUserByIDWithLock failed. id:%d", userID)
}
bank, err := Isubank(tx)

if err != nil {
return nil, errors.Wrap(err, "newIsubank failed")
}
Expand Down Expand Up @@ -131,7 +132,7 @@ func AddOrder(tx *sql.Tx, ot string, userID, amount, price int64) (*Order, error
}

func DeleteOrder(tx *sql.Tx, userID, orderID int64, reason string) error {
user, err := getUserByIDWithLock(tx, userID)
user, err := GetUserByID(tx, userID)
if err != nil {
return errors.Wrapf(err, "getUserByIDWithLock failed. id:%d", userID)
}
Expand Down
4 changes: 0 additions & 4 deletions webapp/go/src/isucon8/isucoin/model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ func GetUserByID(d QueryExecutor, id int64) (*User, error) {
return scanUser(d.Query("SELECT * FROM user WHERE id = ?", id))
}

func getUserByIDWithLock(tx *sql.Tx, id int64) (*User, error) {
return scanUser(tx.Query("SELECT * FROM user WHERE id = ? FOR UPDATE", id))
}

func UserSignup(tx *sql.Tx, name, bankID, password string) error {
bank, err := Isubank(tx)
if err != nil {
Expand Down