Skip to content

Commit

Permalink
Merge pull request #545 from isucon/backend/544_fix-postIsu-deadlock
Browse files Browse the repository at this point in the history
fix(backend): getJIAServiceURLで受け渡されたtxを使うようにした
  • Loading branch information
oribe1115 committed Jul 26, 2021
2 parents c49c7e3 + ebc772d commit 96d2d0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions webapp/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ func getUserIDFromSession(r *http.Request) (string, error) {
return userID.(string), nil
}

func getJIAServiceURL() string {
func getJIAServiceURL(tx *sqlx.Tx) string {
config := Config{}
err := db.Get(&config, "SELECT * FROM `isu_association_config` WHERE `name` = ?", "jia_service_url")
err := tx.Get(&config, "SELECT * FROM `isu_association_config` WHERE `name` = ?", "jia_service_url")
if err != nil {
if !errors.Is(err, sql.ErrNoRows) {
log.Print(err)
Expand Down Expand Up @@ -526,7 +526,7 @@ func postIsu(c echo.Context) error {
}

// JIAにisuのactivateをリクエスト
targetURL := getJIAServiceURL() + "/api/activate"
targetURL := getJIAServiceURL(tx) + "/api/activate"
body := JIAServiceRequest{isuConditionPublicAddress, isuConditionPublicPort, jiaIsuUUID}
bodyJSON, err := json.Marshal(body)
if err != nil {
Expand Down Expand Up @@ -719,7 +719,7 @@ func deleteIsu(c echo.Context) error {
}

// JIAにisuのdeactivateをリクエスト
targetURL := getJIAServiceURL() + "/api/deactivate"
targetURL := getJIAServiceURL(tx) + "/api/deactivate"
body := JIAServiceRequest{isuConditionPublicAddress, isuConditionPublicPort, jiaIsuUUID}
bodyJSON, err := json.Marshal(body)
if err != nil {
Expand Down

0 comments on commit 96d2d0d

Please sign in to comment.