From ef2671927d4f5bdb9eaed29bef84e8fe3bd9ef51 Mon Sep 17 00:00:00 2001 From: littleskunk Date: Fri, 15 May 2020 19:10:26 +0200 Subject: [PATCH] storagenode/piecestore: move queue size defaults (#3881) --- private/testplanet/storagenode.go | 2 ++ storagenode/pieces/deleter.go | 8 -------- storagenode/pieces/deleter_test.go | 9 ++------- storagenode/piecestore/endpoint.go | 4 ++-- 4 files changed, 6 insertions(+), 17 deletions(-) diff --git a/private/testplanet/storagenode.go b/private/testplanet/storagenode.go index f30af3ce7..8567bbab1 100644 --- a/private/testplanet/storagenode.go +++ b/private/testplanet/storagenode.go @@ -135,6 +135,8 @@ func (planet *Planet) newStorageNodes(count int, whitelistedSatellites storj.Nod OrderLimitGracePeriod: time.Hour, StreamOperationTimeout: time.Hour, ReportCapacityThreshold: 100 * memory.MB, + DeleteQueueSize: 10000, + DeleteWorkers: 1, Orders: orders.Config{ SenderInterval: defaultInterval, SenderTimeout: 10 * time.Minute, diff --git a/storagenode/pieces/deleter.go b/storagenode/pieces/deleter.go index 338dc3b9a..5028e674d 100644 --- a/storagenode/pieces/deleter.go +++ b/storagenode/pieces/deleter.go @@ -43,14 +43,6 @@ type Deleter struct { // NewDeleter creates a new Deleter. func NewDeleter(log *zap.Logger, store *Store, numWorkers int, queueSize int) *Deleter { - if numWorkers == 0 { - numWorkers = 1 - } - if queueSize == 0 { - // Default queueSize is chosen as a large number that uses a manageable - // amount of memory. - queueSize = 10000 - } return &Deleter{ ch: make(chan DeleteRequest, queueSize), numWorkers: numWorkers, diff --git a/storagenode/pieces/deleter_test.go b/storagenode/pieces/deleter_test.go index 4d48c2e3a..d58735af2 100644 --- a/storagenode/pieces/deleter_test.go +++ b/storagenode/pieces/deleter_test.go @@ -34,7 +34,7 @@ func TestDeleter(t *testing.T) { store := pieces.NewStore(zaptest.NewLogger(t), blobs, nil, nil, nil, pieces.DefaultConfig) // Also test that 0 works for maxWorkers - deleter := pieces.NewDeleter(zaptest.NewLogger(t), store, 0, 0) + deleter := pieces.NewDeleter(zaptest.NewLogger(t), store, 1, 10000) defer ctx.Check(deleter.Close) deleter.SetupTest() @@ -98,11 +98,6 @@ func TestEnqueueUnhandled(t *testing.T) { pieces: 10, expUnhandled: 9, }, - { - queueSize: 0, // should default to a big number - pieces: 10, - expUnhandled: 0, - }, } for _, tc := range testcases { @@ -111,7 +106,7 @@ func TestEnqueueUnhandled(t *testing.T) { for i := 0; i < tc.pieces; i++ { pieceIDs = append(pieceIDs, testrand.PieceID()) } - deleter := pieces.NewDeleter(zaptest.NewLogger(t), nil, 0, tc.queueSize) + deleter := pieces.NewDeleter(zaptest.NewLogger(t), nil, 1, tc.queueSize) unhandled := deleter.Enqueue(context.Background(), satelliteID, pieceIDs) require.Equal(t, tc.expUnhandled, unhandled) require.NoError(t, deleter.Close()) diff --git a/storagenode/piecestore/endpoint.go b/storagenode/piecestore/endpoint.go index 194455213..647078293 100644 --- a/storagenode/piecestore/endpoint.go +++ b/storagenode/piecestore/endpoint.go @@ -53,8 +53,8 @@ type Config struct { DatabaseDir string `help:"directory to store databases. if empty, uses data path" default:""` ExpirationGracePeriod time.Duration `help:"how soon before expiration date should things be considered expired" default:"48h0m0s"` MaxConcurrentRequests int `help:"how many concurrent requests are allowed, before uploads are rejected. 0 represents unlimited." default:"0"` - DeleteWorkers int `help:"how many piece delete workers" default:"0"` - DeleteQueueSize int `help:"size of the piece delete queue" default:"0"` + DeleteWorkers int `help:"how many piece delete workers" default:"1"` + DeleteQueueSize int `help:"size of the piece delete queue" default:"10000"` OrderLimitGracePeriod time.Duration `help:"how long after OrderLimit creation date are OrderLimits no longer accepted" default:"24h0m0s"` CacheSyncInterval time.Duration `help:"how often the space used cache is synced to persistent storage" releaseDefault:"1h0m0s" devDefault:"0h1m0s"` StreamOperationTimeout time.Duration `help:"how long to spend waiting for a stream operation before canceling" default:"30m"`