storagenode/{orders,piecestore}: Always unlock unsent orders file, even with an empty order.
When we call ordersStore.BeginEnqueue, the unsent orders file for that satellite and hour is prevented from being sent. It is freed when the commit callback returned by BeginEnqueue is used. This change ensures that we always call the commit callback, even when we have an empty order or an order with Amount <= 0. Change-Id: Ic4678f7eaa1e6957dd77d4bb5a23bb35d25b1e93
This commit is contained in:
parent
5729d087b0
commit
68b67c83a7
@ -102,6 +102,11 @@ func (store *FileStore) BeginEnqueue(satelliteID storj.NodeID, createdAt time.Ti
|
||||
// always remove the in flight operation
|
||||
defer store.enqueueFinishedLocked(satelliteID, createdAt)
|
||||
|
||||
// caller wants to abort; free file for sending and return with no error
|
||||
if info == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// check that the info matches what the enqueue was begun with
|
||||
if info.Limit.SatelliteId != satelliteID || !info.Limit.OrderCreation.Equal(createdAt) {
|
||||
return OrderError.New("invalid info passed in to enqueue commit")
|
||||
|
@ -660,12 +660,20 @@ func (endpoint *Endpoint) beginSaveOrder(limit *pb.OrderLimit) (_commit func(ctx
|
||||
|
||||
done := false
|
||||
return func(ctx context.Context, order *pb.Order) {
|
||||
// TODO: do this in a goroutine
|
||||
if order == nil || order.Amount <= 0 || done {
|
||||
if done {
|
||||
return
|
||||
}
|
||||
done = true
|
||||
|
||||
if order == nil || order.Amount <= 0 {
|
||||
// free unsent orders file for sending without writing anything
|
||||
err = commit(nil)
|
||||
if err != nil {
|
||||
endpoint.log.Error("failed to unlock orders file", zap.Error(err))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
err = commit(&orders.Info{Limit: limit, Order: order})
|
||||
if err != nil {
|
||||
endpoint.log.Error("failed to add order", zap.Error(err))
|
||||
|
Loading…
Reference in New Issue
Block a user