Signed-off-by: Seongmin Lee git@boltless.me
+1
-4
appview/db/profile.go
+1
-4
appview/db/profile.go
···
131
131
}
132
132
133
133
func UpsertProfile(tx *sql.Tx, profile *models.Profile) error {
134
-
defer tx.Rollback()
135
-
136
134
// update links
137
135
_, err := tx.Exec(`delete from profile_links where did = ?`, profile.Did)
138
136
if err != nil {
···
228
226
return err
229
227
}
230
228
}
231
-
232
-
return tx.Commit()
229
+
return nil
233
230
}
234
231
235
232
func GetProfiles(e Execer, filters ...orm.Filter) (map[string]*models.Profile, error) {
+6
appview/ingester.go
+6
appview/ingester.go
···
347
347
if err != nil {
348
348
return fmt.Errorf("failed to start transaction")
349
349
}
350
+
defer tx.Rollback()
350
351
351
352
err = db.ValidateProfile(tx, &profile)
352
353
if err != nil {
···
354
355
}
355
356
356
357
err = db.UpsertProfile(tx, &profile)
358
+
if err != nil {
359
+
return fmt.Errorf("upserting profile: %w", err)
360
+
}
361
+
362
+
err = tx.Commit()
357
363
case jmodels.CommitOperationDelete:
358
364
err = db.DeleteArtifact(i.Db, orm.FilterEq("did", did), orm.FilterEq("rkey", e.Commit.RKey))
359
365
}
+12
-5
appview/state/profile.go
+12
-5
appview/state/profile.go
···
613
613
s.pages.Notice(w, "update-profile", "Failed to update profile, try again later.")
614
614
return
615
615
}
616
+
defer tx.Rollback()
617
+
618
+
err = db.UpsertProfile(tx, profile)
619
+
if err != nil {
620
+
log.Println("failed to update profile", err)
621
+
s.pages.Notice(w, "update-profile", "Failed to update profile, try again later.")
622
+
return
623
+
}
616
624
617
625
client, err := s.oauth.AuthorizedClient(r)
618
626
if err != nil {
···
661
669
return
662
670
}
663
671
664
-
err = db.UpsertProfile(tx, profile)
665
-
if err != nil {
666
-
log.Println("failed to update profile", err)
667
-
s.pages.Notice(w, "update-profile", "Failed to update profile, try again later.")
668
-
return
672
+
if err := tx.Commit(); err != nil {
673
+
s.logger.Error("failed to commit transaction", "err", err)
674
+
// db failed, but PDS operation succeed.
675
+
// log error and continue
669
676
}
670
677
671
678
s.notifier.UpdateProfile(r.Context(), profile)
History
2 rounds
0 comments
boltless.me
submitted
#1
1 commit
expand
collapse
appview: move tx rollback logic out of
db.UpsertProfile()
Signed-off-by: Seongmin Lee <git@boltless.me>
2/3 failed, 1/3 success
expand
collapse
merge conflicts detected
expand
collapse
expand
collapse
- appview/issues/issues.go:27
- appview/labels/labels.go:15
- appview/pages/markup/markdown.go:47
- appview/pages/markup/sanitizer.go:10
- appview/pages/pages.go:57
- appview/pulls/pulls.go:27
- appview/repo/repo.go:49
- appview/repo/settings.go:4
- appview/state/router.go:313
- appview/state/state.go:23
- appview/validator/label.go:1
expand 0 comments
boltless.me
submitted
#0
1 commit
expand
collapse
appview: move tx rollback logic out of
db.UpsertProfile()
Signed-off-by: Seongmin Lee <git@boltless.me>