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:
Eli Ribble 2026-05-22 23:19:31 +00:00
parent 7b04822a9b
commit 393836a86a
No known key found for this signature in database
30 changed files with 1126 additions and 72 deletions

View file

@ -8,7 +8,7 @@ import (
"github.com/gorilla/mux"
"github.com/rs/zerolog/log"
"source.gleipnir.technology/Gleipnir/nidus-sync/db/enums"
modelfileupload "source.gleipnir.technology/Gleipnir/nidus-sync/db/gen/nidus-sync/fileupload/model"
nhttp "source.gleipnir.technology/Gleipnir/nidus-sync/http"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform"
"source.gleipnir.technology/Gleipnir/nidus-sync/platform/file"
@ -98,7 +98,7 @@ func (res *uploadR) PoolFlyoverCreate(ctx context.Context, r *http.Request, u pl
return "", nhttp.NewErrorStatus(http.StatusBadRequest, "You must only submit one file at a time")
}
upload := uploads[0]
saved_upload, err := platform.NewUpload(r.Context(), u, upload, enums.FileuploadCsvtypeFlyover)
saved_upload, err := platform.NewUpload(r.Context(), u, upload, modelfileupload.Csvtype_Flyover)
if err != nil {
return "", nhttp.NewError("Failed to create new pool: %w", err)
}
@ -112,7 +112,7 @@ func (res *uploadR) PoolCustomCreate(ctx context.Context, r *http.Request, u pla
return "", nhttp.NewErrorStatus(http.StatusBadRequest, "You must only submit one file at a time")
}
upload := uploads[0]
pool_upload, err := platform.NewUpload(r.Context(), u, upload, enums.FileuploadCsvtypePoollist)
pool_upload, err := platform.NewUpload(r.Context(), u, upload, modelfileupload.Csvtype_PoolList)
if err != nil {
return "", nhttp.NewError("Failed to create new pool: %w", err)
}