File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -680,7 +680,7 @@ class PikaConf : public pstd::BaseConf {
680680 TryPushDiffCommands (" max-background-jobs" , std::to_string (value));
681681 max_background_jobs_ = value;
682682 }
683- void SetWriteBufferSize (const int & value) {
683+ void SetWriteBufferSize (int64_t value) {
684684 std::lock_guard l (rwlock_);
685685 TryPushDiffCommands (" write-buffer-size" , std::to_string (value));
686686 write_buffer_size_ = value;
Original file line number Diff line number Diff line change @@ -2731,7 +2731,7 @@ void ConfigCmd::ConfigSet(std::shared_ptr<DB> db) {
27312731 res_.AppendStringRaw (" -ERR Set write-buffer-size wrong: " + s.ToString () + " \r\n " );
27322732 return ;
27332733 }
2734- g_pika_conf->SetWriteBufferSize (static_cast < int >( ival) );
2734+ g_pika_conf->SetWriteBufferSize (ival);
27352735 res_.AppendStringRaw (" +OK\r\n " );
27362736 } else if (set_item == " max-write-buffer-num" ) {
27372737 if (pstd::string2int (value.data (), value.size (), &ival) == 0 ) {
Original file line number Diff line number Diff line change @@ -329,6 +329,18 @@ var _ = Describe("Server", func() {
329329 Expect (r .Val ()).To (Equal ("OK" ))
330330 })
331331
332+ It ("should ConfigSet write-buffer-size large value" , func () {
333+ // Test for fix: when setting write-buffer-size value larger than 2147483647,
334+ // the value should not become negative
335+ configSet := client .ConfigSet (ctx , "write-buffer-size" , "3000000000" )
336+ Expect (configSet .Err ()).NotTo (HaveOccurred ())
337+ Expect (configSet .Val ()).To (Equal ("OK" ))
338+
339+ configGet := client .ConfigGet (ctx , "write-buffer-size" )
340+ Expect (configGet .Err ()).NotTo (HaveOccurred ())
341+ Expect (configGet .Val ()).To (Equal (map [string ]string {"write-buffer-size" : "3000000000" }))
342+ })
343+
332344 It ("should ConfigSet maxmemory" , func () {
333345 configGet := client .ConfigGet (ctx , "maxmemory" )
334346 Expect (configGet .Err ()).NotTo (HaveOccurred ())
You can’t perform that action at this time.
0 commit comments