-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node/grpc: Change max recv msg size on
MaxObjectSize
setting update
Since storage node serves `ObjectService.Replicate` RPC, the gRPC server must be able to accept the biggest allowed object. Previously, node calculated global message limit for the gRPC server once on startup. With this behavior, when network setting `MaxObjectSize` was increased, the node stopped accepting write objects larger than the previous limit. This manifested itself in a denial of replication service. From now storage node updates max received gRPC message size (if needed) on each refresh of the `MaxObjectSize` setting cache and via Netmap contract's polling done once per minute. Refs #2910. Signed-off-by: Leonard Lyubich <[email protected]>
- Loading branch information
1 parent
8d0ac07
commit 19f39df
Showing
8 changed files
with
160 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap" | ||
) | ||
|
||
func Test_calculateMaxReplicationRequestSize(t *testing.T) { | ||
limit, _ := calculateMaxReplicationRequestSize(64 << 20) | ||
require.EqualValues(t, 67126272, limit) | ||
t.Run("int overflow", func(t *testing.T) { | ||
limit, overflow := calculateMaxReplicationRequestSize(math.MaxInt - 17<<10 + 1) | ||
require.Negative(t, limit) | ||
require.EqualValues(t, uint64(math.MaxInt)+1, overflow) | ||
}) | ||
t.Run("uint64 overflow", func(t *testing.T) { | ||
limit, overflow := calculateMaxReplicationRequestSize(math.MaxUint64 - 17<<10 + 1) | ||
require.Negative(t, limit) | ||
require.EqualValues(t, uint64(math.MaxUint64), overflow) | ||
}) | ||
t.Run("smaller than gRPC default", func(t *testing.T) { | ||
limit, _ := calculateMaxReplicationRequestSize(0) | ||
require.EqualValues(t, 4<<20, limit) | ||
limit, _ = calculateMaxReplicationRequestSize(4<<20 - 17<<10 - 1) | ||
require.EqualValues(t, 4<<20, limit) | ||
}) | ||
} | ||
|
||
func Test_cfg_handleNewMaxObjectPayloadSize(t *testing.T) { | ||
var c cfg | ||
c.log = zap.NewNop() | ||
c.cfgGRPC.maxRecvMsgSize.Store(0) // any | ||
|
||
c.handleNewMaxObjectPayloadSize(100 << 20) | ||
require.EqualValues(t, 100<<20+17<<10, c.cfgGRPC.maxRecvMsgSize.Load()) | ||
c.handleNewMaxObjectPayloadSize(64 << 20) | ||
require.EqualValues(t, 64<<20+17<<10, c.cfgGRPC.maxRecvMsgSize.Load()) | ||
// int overflow | ||
c.handleNewMaxObjectPayloadSize(math.MaxInt - 17<<10 + 1) | ||
require.EqualValues(t, math.MaxInt, c.cfgGRPC.maxRecvMsgSize.Load()) | ||
// uint64 overflow | ||
c.handleNewMaxObjectPayloadSize(math.MaxUint64 - 17<<10 + 1) | ||
require.EqualValues(t, math.MaxInt, c.cfgGRPC.maxRecvMsgSize.Load()) | ||
// smaller than gRPC default | ||
c.handleNewMaxObjectPayloadSize(4<<20 - 17<<10 - 1) | ||
require.EqualValues(t, 4<<20, c.cfgGRPC.maxRecvMsgSize.Load()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters