OpenAtomFoundation / pikiwidb

a high-performance, large-capacity, multi-tenant, data-persistent, strong data consistency based on raft, Redis-compatible elastic KV data storage system based on RocksDB
BSD 3-Clause "New" or "Revised" License
194 stars 63 forks source link

bug: do not config worker-threads and slave-threads, program will abnormal quit #286

Closed hahahashen closed 4 months ago

hahahashen commented 4 months ago

Is this a regression?

Yes

Description

当前有配置文件运行项目时,如果配置文件中没有指定worker-threads以及slave-threads,那么LoadPikiwiDBConfig函数的语句 cfg.worker_threads_num = parser.GetData("worker-threads", 1); cfg.slave_threads_num = parser.GetData("slave-threads", 1);就会设置.worker_threads_num、slave_threads_num 变量为1,而在IOThreadPool::SetWorkerNum函数处就会直接返回,导致IOThreadPool的成员变量worker_num_为初始值0,导致void WorkIOThreadPool::PushWriteTask(std::sharedptr client) 函数中出现除0错误,auto pos = ++counter % workernum;使得程序异常退出

解决方案: 方案1:设置默认值处,默认值设置为2 方案2:考虑IOThreadPool::SetWorkerNum函数if (num <= 1) 改为if (num <1)

Please provide a link to a minimal reproduction of the bug

No response

Screenshots or videos

image image image image

Please provide the version you discovered this bug in (check about page for version information)

commit hash:57248c3b612a5c2bf0a89586262b616eff1ffde4

Anything else?

No response

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Title: bug:

AlexStocks commented 4 months ago

这个 issue title 怎么是空的

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Why is this issue title empty?

hahahashen commented 4 months ago

这个 issue title 怎么是空的 刚刚编辑上了= =

Issues-translate-bot commented 4 months ago

Bot detected the issue body's language is not English, translate it automatically.


Why is this issue title empty? Just edited it = =

hahahashen commented 4 months ago

或者运行的时候conf指定worker-threads以及slave-threads为1时也会导致运行时程序异常退出