osd: Let the event loop run between PG peering calculations #197
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:osd-peering-yield"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
handle_peers() (src/osd/osd_peering.cpp:24) calls ringloop->wakeup() after each calc_object_states(). But wakeup() only makes ring_loop_t::loop() run the consumers again in the same pass (src/util/ringloop.cpp:94-169), and completions are read only at the start of a pass. So an OSD that is primary for several PGs whose LISTs are all in computes all of them back to back. Pings, timers and the etcd lease renewal wait for the whole series.
With EC 8+2 and ~850k objects per PG, one calculation takes 1-3 s, and a weight change made one OSD primary for up to 11 peering PGs at once. Peers dropped that OSD by osd_ping_timeout, which started peering again, and the cluster kept re-peering.
The change: after each calculation, arm a 1 ms timer (
tfd->set_timer(), the same one-shot timer as the pause between reshard chunks) and start the next calculation when it fires. The loop then reads what came in during the calculation, and the reads and sends that starts have time to finish. A NOP is not enough: a ping needs an epoll event, a recvmsg completion and a send. In a test the recvmsg completion came one drain after the NOP's, so the number of passes to wait for depends on kernel timing.Found: seen in a run. On a cluster with ~850k objects per PG, OSDs stopped answering pings for many seconds while they peered several PGs, peers dropped them, and the PGs peered again in a loop.
Tested:
Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA
682224f9f6toa8a7c41983a8a7c41983to7f843c8a5ace3e8e2f75to66733b1369