osd: Don't exit on finding own state key, arm lease timers only after the grant #186

Open
koolkhel wants to merge 2 commits from koolkhel/vitastor:osd-own-lease-stats-timer into master
Contributor

Description

Two fixes for OSDs that start while etcd answers slower than etcd_quick_timeout, for example when many OSDs start at once.

  1. The reply to the /osd/state/N creation transaction can time out even though etcd has already applied it. The retry then finds the key with the OSD's own lease, and the OSD exits with "Key ... already exists in etcd, OSD N is still up". It is restarted only to repeat the same start against the same slow etcd. A key that holds our own lease now counts as created.
  2. acquire_lease() armed the periodic lease renewal and statistics timers on every call. Each failed lease grant left one more renewal timer and one more statistics timer running for the life of the process, which multiplied the keepalive and statistics load on etcd exactly when it was already overloaded. The timers are now armed once, when the lease is granted.

Found: the exit on the OSD's own state key was seen on a 16-node test stand with 3840 OSDs at cold start: 259 of 951 "already exists" exits came right after a timeout of the create transaction in the same process. The stats timer armed on every grant call was found by reading the code.

Tested with a proxy in front of etcd that holds back the reply to each OSD's first state key creation for 1.5 s. On master all three OSDs find their own key, print "already exists ... still up" and exit, so the pool never comes up. With the fix all OSDs come up. The test is left out of this PR, as asked in review. It merges cleanly with #140, which also touches acquire_lease(). The timer change has no test of its own.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description Two fixes for OSDs that start while etcd answers slower than `etcd_quick_timeout`, for example when many OSDs start at once. 1. The reply to the `/osd/state/N` creation transaction can time out even though etcd has already applied it. The retry then finds the key with the OSD's own lease, and the OSD exits with "Key ... already exists in etcd, OSD N is still up". It is restarted only to repeat the same start against the same slow etcd. A key that holds our own lease now counts as created. 2. `acquire_lease()` armed the periodic lease renewal and statistics timers on every call. Each failed lease grant left one more renewal timer and one more statistics timer running for the life of the process, which multiplied the keepalive and statistics load on etcd exactly when it was already overloaded. The timers are now armed once, when the lease is granted. Found: the exit on the OSD's own state key was seen on a 16-node test stand with 3840 OSDs at cold start: 259 of 951 "already exists" exits came right after a timeout of the create transaction in the same process. The stats timer armed on every grant call was found by reading the code. Tested with a proxy in front of etcd that holds back the reply to each OSD's first state key creation for 1.5 s. On master all three OSDs find their own key, print "already exists ... still up" and exit, so the pool never comes up. With the fix all OSDs come up. The test is left out of this PR, as asked in review. It merges cleanly with #140, which also touches `acquire_lease()`. The timer change has no test of its own. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-25 09:22:40 +03:00
When the reply to the /osd/state creation transaction was lost (timeout)
but etcd applied it, the retry found the key with the OSD's own lease
and the OSD exited with "already exists, OSD N is still up". Treat a key
holding our own lease as created.

acquire_lease() armed the periodic renewal and statistics timers on every
call, so each failed lease grant added one more of each. Arm them once,
when the lease is granted.
vitalif requested changes 2026-11-25 21:14:35 +03:00
vitalif left a comment
Owner

Давай замержим без теста

Давай замержим без теста
koolkhel added 1 commit 2026-11-25 22:48:31 +03:00
Author
Contributor

убрал

убрал
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u osd-own-lease-stats-timer:koolkhel-osd-own-lease-stats-timer
git checkout koolkhel-osd-own-lease-stats-timer
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#186
No description provided.