Pull to refresh

Comments 8

Годнота, конечно, но:

Было обещано лишь, что «лидер будет найден, если большинство узлов работоспособно и связано друг с другом»

Условие связности большинства в первых примерах не выполняется, потому что A и C не связаны, а один B не составляет большинство. Или я неправильно понял что-то из базовых определений оригинальной статьи про рафт?

Почему же, большинство в кластере из 3 узлов - 2, A и B в примерах связаны. "Большинство" имеется в виду, считая себя самого, то есть A связан с самим собой и с B, и этого достаточно.

Если бы для 3 узлов рафт требовал связи с большинством, не считая себя, то кластер бы терял работоспособность, как только первый же узел отказал.

Да, теперь понятно, спасибо.

Наше отклонение от канонической реализации позволило ускорить выборы с помощью обнаружения ничьей, и в то же время потребовало дополнительных модификаций для обеспечения консисентости

https://lists.gnu.org/archive/html/bug-bash/2017-03/msg00171.html

Once upon a time, a man with a dirty lab coat and long, uncombed hair
showed up at the town police station, demanding to see the chief of
police. "I've done it!" he exclaimed. "I've built the perfect
criminal-catching robot!"

The police chief was skeptical, but decided that it might be worth
the time to see what the man had invented. Also, he secretly thought,
it might be a somewhat unwise move to completely alienate the mad
scientist and his army of hunter robots.

So, the man explained to the police chief how his invention could tell
the difference between a criminal and law-abiding citizen using a
series of heuristics. "It's especially good at spotting recently
escaped prisoners!" he said. "Guaranteed non-lethal restraints!"

Frowning and increasingly skeptical, the police chief nevertheless
allowed the man to demonstrate one robot for a week. They decided that
the robot should patrol around the jail. Sure enough, there was a
jailbreak a few days later, and an inmate digging up through the
ground outside of the prison facility was grabbed by the robot and
carried back inside the prison.

The surprised police chief allowed the robot to patrol a wider area.
The next day, the chief received an angry call from the zookeeper.
It seems the robot had cut through the bars of one of the animal cages,
grabbed the animal, and delivered it to the prison.

The chief confronted the robot's inventor, who asked what animal it
was. "A zebra," replied the police chief. The man slapped his head and
exclaimed, "Curses! It was fooled by the black and white stripes!
I shall have to recalibrate!" And so the man set about rewriting the
robot's code. Black and white stripes would indicate an escaped
inmate UNLESS the inmate had more than two legs. Then it should be
left alone.

The robot was redeployed with the updated code, and seemed to be
operating well enough for a few days. Then on Saturday, a mob of
children in soccer clothing, followed by their parents, descended
on the police station. After the chaos subsided, the chief was told
that the robot had absconded with the referee right in the middle of
a soccer game.

Scowling, the chief reported this to the scientist, who performed a
second calibration. Black and white stripes would indicate an escaped
inmate UNLESS the inmate had more than two legs OR had a whistle on
a necklace.

Despite the second calibration, the police chief declared that the robot
would no longer be allowed to operate in his town. However, the news
of the robot had spread, and requests from many larger cities were
pouring in. The inventor made dozens more robots, and shipped them off
to eager police stations around the nation. Every time a robot grabbed
something that wasn't an escaped inmate, the scientist was consulted,
and the robot was recalibrated.

Unfortunately, the inventor was just one man, and he didn't have the
time or the resources to recalibrate EVERY robot whenever one of them
went awry. The robot in Shangri-La was recalibrated not to grab a
grave-digger working on a cold winter night while wearing a ski mask,
and the robot in Xanadu was recalibrated not to capture a black and
white television set that showed a movie about a prison break, and so
on. But the robot in Xanadu would still grab grave-diggers with ski
masks (which it turns out was not common due to Xanadu's warmer climate),
and the robot in Shangri-La was still a menace to old televisions (of
which there were very few, the people of Shangri-La being on the average
more wealthy than those of Xanadu).

So, after a few years, there were different revisions of the
criminal-catching robot in most of the major cities. In some places,
a clever criminal could avoid capture by wearing a whistle on a string
around the neck. In others, one would be well-advised not to wear orange
clothing in certain rural areas, no matter how close to the Harvest
Festival it was, unless one also wore the traditional black triangular
eye-paint of the Pumpkin King.

Many people thought, "This is lunacy!" But others thought the robots
did more good than harm, all things considered, and so in some places
the robots are used, while in other places they are shunned.

The end.

по причине потери связи одним из участников я в реализации рафта для Ergo Framework ввел понятие кворума. https://github.com/ergo-services/ergo/blob/master/gen/raft.go

Это гарантия связности всех участников. Сама по себе спецификация рафта - это свод рекомендаций, не более. Рассматривать ее как реальную спеку весьма сложно.

по причине потери связи одним из участников я в реализации рафта для Ergo Framework ввел понятие кворума. https://github.com/ergo-services/ergo/blob/master/gen/raft.go

Насколько я понимаю, у вас в кластере есть подгруппа узлов, которые могут голосовать, а остальные - learners? А что происходит, когда кто-то из кворума отказывает или с ним теряется связь? Находят нового члена кворума?

Отличная статья, действительно, в большинстве случаев думают об узлах, забывают о сети.

Отмечу , что эти надстройки заметно улучшают стабильность работы кластера, однако, как я понял, checkQuorum и PreVoute работают последовательно перед голосованием. И если у нас наблюдаются частые мигания сети (например маршрутизатор "сошёл с ума") то есть вероятность, что ситуация Х случится после проверок, но до голосования... А тут уж как карта ляжет и можно вернуться к одному из негативных сценариев, описанных в статье...

CheckQuorum работает постоянно на лидере, и частые, но кратковременные мигания переносит спокойно. А если сеть теряется часто и надолго, то на каждую такую потерю сети лидер будет складывать полномочия, и будут начинаться новые выборы.

PreVote действительно отрабатывает перед голосованием, и можно представить такой набор "миганий", что большинство перестанет видеть лидера, кто-то из большинства проведёт проверку Pre-Vote и начнёт голосование. От этого ни оригинальный Raft, ни Pre-Vote не защищают. Можно election_timeout менять разве что. Чем больше таймаут, тем более долгие мигания можно пережить без смены лидера. Но и время реакции на настоящий отказ лидера увеличивается.

Sign up to leave a comment.