Fix notification of job happening before transaction is closed
This is kind of a wild one. Turns out that the triggers I was using actually fire before the transaction is closed and I was primarily getting lucky that the job was present on the other side of the connection rather than having things built correctly. I've fixed this by removing the trigger entirely and instead manually triggering as part of the transaction. This makes the NOTIFY call happen as soon as the transaction closes, just at the cost of making my application be in charge of ensuring the NOTIFY gets called. Seems like a win. Part of doing this is porting the existing job creation code over to use Jet. It's something I want to do anyway, so it's a win all around.
This commit is contained in:
parent
7b04822a9b
commit
393836a86a
30 changed files with 1126 additions and 72 deletions
|
|
@ -65,18 +65,20 @@ func HandleTextMessage(ctx context.Context, source string, destination string, c
|
|||
if err := txn.Commit(ctx); err != nil {
|
||||
return fmt.Errorf("commit: %w", err)
|
||||
}
|
||||
log.Debug().Msg("commit handle text message")
|
||||
return err
|
||||
}
|
||||
|
||||
func respondText(ctx context.Context, log_id int32) error {
|
||||
txn, err := db.BeginTxn(ctx)
|
||||
log.Debug().Msg("respond text txn begin")
|
||||
if err != nil {
|
||||
return fmt.Errorf("begin tx: %w", err)
|
||||
}
|
||||
defer lint.LogOnErrRollback(txn.Rollback, ctx, "rollback")
|
||||
l, err := querycomms.TextLogFromID(ctx, txn, int64(log_id))
|
||||
if err != nil {
|
||||
return fmt.Errorf("find comms: %w", err)
|
||||
return fmt.Errorf("find comms %d: %w", log_id, err)
|
||||
}
|
||||
src, err := ParsePhoneNumber(l.Source)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue