feat(background): mark the payload-type backfill done at once when no observation is untyped (#244)

This commit is contained in:
MrAlders0n authored and GitHub committed 2026-10-19 19:44:22 -04:00
1 parent ded8708fec
commit d4e85cbf90
9 files changed
+420 -2

No files matched your search

+15
View File
@@ -1330,6 +1330,21 @@ func (mr *MockQuerierMockRecorder) GetTransportScopes(ctx any) *gomock.Call {
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTransportScopes", reflect.TypeOf((*MockQuerier)(nil).GetTransportScopes), ctx)
}
// HasUntypedObservations mocks base method.
func (m *MockQuerier) HasUntypedObservations(ctx context.Context, maxID int64) (bool, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HasUntypedObservations", ctx, maxID)
ret0, _ := ret[0].(bool)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// HasUntypedObservations indicates an expected call of HasUntypedObservations.
func (mr *MockQuerierMockRecorder) HasUntypedObservations(ctx, maxID any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasUntypedObservations", reflect.TypeOf((*MockQuerier)(nil).HasUntypedObservations), ctx, maxID)
}
// InsertChannelMessage mocks base method.
func (m *MockQuerier) InsertChannelMessage(ctx context.Context, arg db.InsertChannelMessageParams) (db.InsertChannelMessageRow, error) {
m.ctrl.T.Helper()
+3
View File
@@ -192,6 +192,9 @@ type Querier interface {
GetTopNodesProbe(ctx context.Context, arg GetTopNodesProbeParams) ([]GetTopNodesProbeRow, error)
GetTransportScopeByName(ctx context.Context, name string) (int32, error)
GetTransportScopes(ctx context.Context) ([]GetTransportScopesRow, error)
// Whether any observation up to @max_id lacks a payload type. A full scan, run at most once per
// process by the payload-type backfill.
HasUntypedObservations(ctx context.Context, maxID int64) (bool, error)
// ============================================================
// CHANNEL MESSAGES
// ============================================================
+16
View File
@@ -2694,6 +2694,22 @@ func (q *Queries) GetTransportScopes(ctx context.Context) ([]GetTransportScopesR
return items, nil
}
const hasUntypedObservations = `-- name: HasUntypedObservations :one
SELECT EXISTS (
SELECT 1 FROM packet_observations
WHERE payload_type IS NULL AND id <= $1::bigint
) AS untyped
`
// Whether any observation up to @max_id lacks a payload type. A full scan, run at most once per
// process by the payload-type backfill.
func (q *Queries) HasUntypedObservations(ctx context.Context, maxID int64) (bool, error) {
row := q.db.QueryRow(ctx, hasUntypedObservations, maxID)
var untyped bool
err := row.Scan(&untyped)
return untyped, err
}
const insertChannelMessage = `-- name: InsertChannelMessage :one
WITH inserted AS (