···3737 // Once done it clears the buffer and marks the job as "complete"
3838 // Allowing the Job interface to abstract away the details of how buffered
3939 // operations are stored and/or locked
4040- FlushBufferedOps(ctx context.Context, cb func(kind, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error) error
4040+ FlushBufferedOps(ctx context.Context, cb func(kind, rev, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error) error
41414242 ClearBufferedOps(ctx context.Context) error
4343}
···5656// Backfiller is a struct which handles backfilling a repo
5757type Backfiller struct {
5858 Name string
5959- HandleCreateRecord func(ctx context.Context, repo string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error
6060- HandleUpdateRecord func(ctx context.Context, repo string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error
6161- HandleDeleteRecord func(ctx context.Context, repo string, path string) error
5959+ HandleCreateRecord func(ctx context.Context, repo string, rev string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error
6060+ HandleUpdateRecord func(ctx context.Context, repo string, rev string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error
6161+ HandleDeleteRecord func(ctx context.Context, repo string, rev string, path string) error
6262 Store Store
63636464 // Number of backfills to process in parallel
···120120func NewBackfiller(
121121 name string,
122122 store Store,
123123- handleCreate func(ctx context.Context, repo string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error,
124124- handleUpdate func(ctx context.Context, repo string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error,
125125- handleDelete func(ctx context.Context, repo string, path string) error,
123123+ handleCreate func(ctx context.Context, repo string, rev string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error,
124124+ handleUpdate func(ctx context.Context, repo string, rev string, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error,
125125+ handleDelete func(ctx context.Context, repo string, rev string, path string) error,
126126 opts *BackfillOptions,
127127) *Backfiller {
128128 if opts == nil {
···210210211211 // Flush buffered operations, clear the buffer, and mark the job as "complete"
212212 // Clearning and marking are handled by the job interface
213213- err := job.FlushBufferedOps(ctx, func(kind, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error {
213213+ err := job.FlushBufferedOps(ctx, func(kind, rev, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error {
214214 switch repomgr.EventKind(kind) {
215215 case repomgr.EvtKindCreateRecord:
216216- err := b.HandleCreateRecord(ctx, repo, path, rec, cid)
216216+ err := b.HandleCreateRecord(ctx, repo, rev, path, rec, cid)
217217 if err != nil {
218218 log.Error("failed to handle create record", "error", err)
219219 }
220220 case repomgr.EvtKindUpdateRecord:
221221- err := b.HandleUpdateRecord(ctx, repo, path, rec, cid)
221221+ err := b.HandleUpdateRecord(ctx, repo, rev, path, rec, cid)
222222 if err != nil {
223223 log.Error("failed to handle update record", "error", err)
224224 }
225225 case repomgr.EvtKindDeleteRecord:
226226- err := b.HandleDeleteRecord(ctx, repo, path)
226226+ err := b.HandleDeleteRecord(ctx, repo, rev, path)
227227 if err != nil {
228228 log.Error("failed to handle delete record", "error", err)
229229 }
···375375 log.Error("failed to iterated records in repo", "err", err)
376376 }
377377 }()
378378+379379+ rev := r.SignedCommit().Rev
378380379381 // Consumer routines
380382 for i := 0; i < numRoutines; i++ {
···399401 continue
400402 }
401403402402- err = b.HandleCreateRecord(ctx, repoDid, item.recordPath, recM, &item.nodeCid)
404404+ err = b.HandleCreateRecord(ctx, repoDid, rev, item.recordPath, recM, &item.nodeCid)
403405 if err != nil {
404406 recordResults <- recordResult{recordPath: item.recordPath, err: fmt.Errorf("failed to handle create record: %w", err)}
405407 continue
···509511 for _, op := range ops {
510512 switch op.kind {
511513 case "create":
512512- if err := bf.HandleCreateRecord(ctx, evt.Repo, op.path, op.rec, op.cid); err != nil {
514514+ if err := bf.HandleCreateRecord(ctx, evt.Repo, evt.Rev, op.path, op.rec, op.cid); err != nil {
513515 return fmt.Errorf("create record failed: %w", err)
514516 }
515517 case "update":
516516- if err := bf.HandleUpdateRecord(ctx, evt.Repo, op.path, op.rec, op.cid); err != nil {
518518+ if err := bf.HandleUpdateRecord(ctx, evt.Repo, evt.Rev, op.path, op.rec, op.cid); err != nil {
517519 return fmt.Errorf("update record failed: %w", err)
518520 }
519521 case "delete":
520520- if err := bf.HandleDeleteRecord(ctx, evt.Repo, op.path); err != nil {
522522+ if err := bf.HandleDeleteRecord(ctx, evt.Repo, evt.Rev, op.path); err != nil {
521523 return fmt.Errorf("delete record failed: %w", err)
522524 }
523525 }
+2-2
backfill/gormstore.go
···303303 return j.db.Save(j.dbj).Error
304304}
305305306306-func (j *Gormjob) FlushBufferedOps(ctx context.Context, fn func(kind, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error) error {
306306+func (j *Gormjob) FlushBufferedOps(ctx context.Context, fn func(kind, rev, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error) error {
307307 // TODO: this will block any events for this repo while this flush is ongoing, is that okay?
308308 j.lk.Lock()
309309 defer j.lk.Unlock()
···325325 }
326326327327 for _, op := range opset.ops {
328328- if err := fn(op.kind, op.path, op.rec, op.cid); err != nil {
328328+ if err := fn(op.kind, opset.rev, op.path, op.rec, op.cid); err != nil {
329329 return err
330330 }
331331 }
+1-1
backfill/memstore.go
···174174 return nil
175175}
176176177177-func (j *Memjob) FlushBufferedOps(ctx context.Context, fn func(kind, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error) error {
177177+func (j *Memjob) FlushBufferedOps(ctx context.Context, fn func(kind, rev, path string, rec typegen.CBORMarshaler, cid *cid.Cid) error) error {
178178 panic("TODO: copy what we end up doing from the gormstore")
179179 /*
180180 j.lk.Lock()
+2-2
search/firehose.go
···174174 log.Info("finished repo discovery", "totalJobs", total, "totalErrored", totalErrored)
175175}
176176177177-func (s *Server) handleCreateOrUpdate(ctx context.Context, rawDID string, path string, rec typegen.CBORMarshaler, rcid *cid.Cid) error {
177177+func (s *Server) handleCreateOrUpdate(ctx context.Context, rawDID string, rev string, path string, rec typegen.CBORMarshaler, rcid *cid.Cid) error {
178178 // Since this gets called in a backfill job, we need to check if the path is a post or profile
179179 if !strings.Contains(path, "app.bsky.feed.post") && !strings.Contains(path, "app.bsky.actor.profile") {
180180 return nil
···211211 return nil
212212}
213213214214-func (s *Server) handleDelete(ctx context.Context, rawDID, path string) error {
214214+func (s *Server) handleDelete(ctx context.Context, rawDID, rev, path string) error {
215215 // Since this gets called in a backfill job, we need to check if the path is a post or profile
216216 if !strings.Contains(path, "app.bsky.feed.post") && !strings.Contains(path, "app.bsky.actor.profile") {
217217 return nil