Fix 'empty queue' error when satellite starts (#939)

This commit is contained in:
Michal Niewrzal 2019-01-02 17:00:32 +01:00 committed by GitHub
parent e4b3dab446
commit b712fbcbb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 6 deletions

View File

@ -49,7 +49,7 @@ func (q *Queue) Enqueue(ctx context.Context, qi *pb.InjuredSegment) error {
func (q *Queue) Dequeue(ctx context.Context) (pb.InjuredSegment, error) {
val, err := q.db.Dequeue()
if err != nil {
if err == storage.ErrEmptyQueue {
if storage.ErrEmptyQueue.Has(err) {
return pb.InjuredSegment{}, err
}
return pb.InjuredSegment{}, Error.New("error obtaining item from repair queue %s", err)

View File

@ -62,7 +62,7 @@ func (service *repairService) Run(ctx context.Context) (err error) {
func (service *repairService) process(ctx context.Context) error {
seg, err := service.queue.Dequeue(ctx)
if err != nil {
if err == storage.ErrEmptyQueue {
if storage.ErrEmptyQueue.Has(err) {
return nil
}
return err

View File

@ -42,7 +42,7 @@ func (r *repairQueue) Dequeue(ctx context.Context) (pb.InjuredSegment, error) {
if err != nil {
return pb.InjuredSegment{}, Error.Wrap(utils.CombineErrors(err, tx.Rollback()))
} else if res == nil {
return pb.InjuredSegment{}, Error.Wrap(utils.CombineErrors(storage.ErrEmptyQueue, tx.Rollback()))
return pb.InjuredSegment{}, Error.Wrap(utils.CombineErrors(storage.ErrEmptyQueue.New(""), tx.Rollback()))
}
deleted, err := tx.Delete_Injuredsegment_By_Id(

View File

@ -20,7 +20,7 @@ var ErrKeyNotFound = errs.Class("key not found")
var ErrEmptyKey = errs.Class("empty key")
// ErrEmptyQueue is returned when attempting to Dequeue from an empty queue
var ErrEmptyQueue = errors.New("empty queue")
var ErrEmptyQueue = errs.Class("empty queue")
// ErrLimitExceeded is returned when request limit is exceeded
var ErrLimitExceeded = errors.New("limit exceeded")

View File

@ -45,7 +45,7 @@ func (client *Queue) Dequeue() (storage.Value, error) {
out, err := client.db.RPop(queueKey).Bytes()
if err != nil {
if err == redis.Nil {
return nil, storage.ErrEmptyQueue
return nil, storage.ErrEmptyQueue.New("")
}
return nil, Error.New("dequeue error: %v", err)
}

View File

@ -38,7 +38,7 @@ func (q *Queue) Dequeue() (storage.Value, error) {
q.s.Remove(e) // Dequeue
return e.Value.(storage.Value), nil
}
return nil, storage.ErrEmptyQueue
return nil, storage.ErrEmptyQueue.New("")
}
//Peekqueue gets upto 'limit' entries from the list queue