Rework background jobs to make transactions much shorter
I ended up with minutes-long open transactions in the database in prod which was causing outtages. This is because I thought transactions were basically free, which is a terrible thing to think. Instead we'll just open them when we need them.
This commit is contained in:
parent
55cb4ca962
commit
ade629ecf5
11 changed files with 118 additions and 87 deletions
|
|
@ -9,7 +9,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/bob"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/comms/email"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/config"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
|
|
@ -116,8 +115,9 @@ func sendEmailBegin(ctx context.Context, source string, destination string, temp
|
|||
}
|
||||
return background.NewEmailSend(ctx, db.PGInstance.BobDB, *e)
|
||||
}
|
||||
func sendEmailComplete(ctx context.Context, txn bob.Executor, email_id int32) error {
|
||||
email_log, err := models.FindCommsEmailLog(ctx, txn, email_id)
|
||||
func sendEmailComplete(ctx context.Context, email_id int32) error {
|
||||
bxn := db.PGInstance.BobDB
|
||||
email_log, err := models.FindCommsEmailLog(ctx, bxn, email_id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("find email: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue