Skip to content

Commit

Permalink
fix: sql query fix + logging cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
smrz2001 committed Jul 28, 2023
1 parent beef7b4 commit 4fcd77c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/db/anchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewAnchorDb(logger models.Logger) *AnchorDatabase {
}

func (adb *AnchorDatabase) GetRequests(ctx context.Context, status models.RequestStatus, newerThan time.Time, olderThan time.Time, limit int) ([]*models.AnchorRequest, error) {
query := "SELECT REQ.id, REQ.cid, REQ.stream_id, REQ.origin, REQ.timestamp, REQ.created_at, META.metadata FROM request AS REQ LEFT JOIN metadata AS META USING (stream_id) WHERE status = $1 AND REQ.created_at > $2 AND created_at < $3 ORDER BY REQ.created_at LIMIT $4"
query := "SELECT REQ.id, REQ.cid, REQ.stream_id, REQ.origin, REQ.timestamp, REQ.created_at, META.metadata FROM request AS REQ LEFT JOIN metadata AS META USING (stream_id) WHERE status = $1 AND REQ.created_at > $2 AND REQ.created_at < $3 ORDER BY REQ.created_at LIMIT $4"
return adb.query(
ctx,
query,
Expand Down
5 changes: 4 additions & 1 deletion services/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ func (b BatchingService) batch(ctx context.Context, anchorReqs []*models.AnchorR
}
b.metricService.Count(ctx, models.MetricName_BatchCreated, 1)
b.metricService.Distribution(ctx, models.MetricName_BatchSize, batchSize)
b.logger.Infof("generated %v", anchorReqBatch)
b.logger.Debugw(
"batch generated",
"batch", anchorReqBatch,
)
return batchResults, nil
}

Expand Down
6 changes: 5 additions & 1 deletion services/poll.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ func (p RequestPoller) Run(ctx context.Context) {
// It's possible the checkpoint was updated even if a particular request in the batch failed to be
// queued.
if nextCheckpoint := p.sendRequestMessages(ctx, anchorReqMsgs); nextCheckpoint.After(startCheckpoint) {
p.logger.Debugf("old=%s, new=%s", startCheckpoint, nextCheckpoint)
p.logger.Debugw(
"checkpoints",
"start", startCheckpoint,
"next", nextCheckpoint,
)
if _, err = p.stateDb.UpdateCheckpoint(ctx, models.CheckpointType_RequestPoll, nextCheckpoint); err != nil {
p.logger.Errorf("error updating checkpoint %s: %v", nextCheckpoint, err)
} else {
Expand Down
2 changes: 1 addition & 1 deletion services/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (w WorkerService) createJobs(ctx context.Context) error {
}
}
w.logger.Debugw(
"counts",
"job counts",
"numJobsRequired", numJobsRequired,
"numExistingJobs", numExistingJobs,
"numJobsAllowed", numJobsAllowed,
Expand Down

0 comments on commit 4fcd77c

Please sign in to comment.