satellite/satellitedb: emergency temporary order processing semaphore

we have thundering herds of order submissions that take all of the
database connections causing temporary periodic outages. limit
the amount of concurrent order processing to 2.

Change-Id: If3f86cdbd21085a4414c2ff17d9ef6d8839a6c2b
This commit is contained in:
Jeff Wendling 2020-10-08 13:00:24 -04:00 committed by Stefan Benten
parent ad8da61dac
commit 7c303208ff

View File

@ -241,6 +241,8 @@ func (db *ordersDB) UnuseSerialNumber(ctx context.Context, serialNumber storj.Se
return err
}
var processSem = make(chan struct{}, 2)
// ProcessOrders take a list of order requests and inserts them into the pending serials queue.
//
// ProcessOrders requires that all orders come from the same storage node.
@ -251,6 +253,14 @@ func (db *ordersDB) ProcessOrders(ctx context.Context, requests []*orders.Proces
return nil, nil
}
// bound the number of orders we issue at once to avoid herds using all the database connections
select {
case processSem <- struct{}{}:
defer func() { <-processSem }()
case <-ctx.Done():
return nil, ctx.Err()
}
// check that all requests are from the same storage node
storageNodeID := requests[0].OrderLimit.StorageNodeId
for _, req := range requests[1:] {