Skip to content

Fix several bugs with ZooKeeper client#21264

Merged
alexey-milovidov merged 3 commits intomasterfrom
fix_zookeeper_update
Feb 27, 2021
Merged

Fix several bugs with ZooKeeper client#21264
alexey-milovidov merged 3 commits intomasterfrom
fix_zookeeper_update

Conversation

@alesapin
Copy link
Copy Markdown
Member

@alesapin alesapin commented Feb 26, 2021

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix redundant reconnects to ZooKeeper and the possibility of two active sessions for a single clickhouse server. Both problems introduced in #14678.

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Feb 26, 2021
@alesapin alesapin changed the title Fix redundant zookeeper reconnect and possibility of multiple zookeep… Fix several bugs with ZooKeeper client Feb 26, 2021
@alexey-milovidov alexey-milovidov self-assigned this Feb 26, 2021
@azat
Copy link
Copy Markdown
Member

azat commented Feb 26, 2021

But does this fixes some real issues (if so, than what are they?) or just fixes the excessive connections to zookeeper?

@alexey-milovidov
Copy link
Copy Markdown
Member

Yes, it is fixing a pile of issues.

Without forcefully invalidating ZooKeeper session before establishing a new one, there was a possibility that server is using two ZooKeeper sessions simultaneously in different parts of code. This is stong antipattern and we are aware of it and always prevented it until it was broken in #14678.

ZooKeeper is linearizeable for writes, but not linearizeable for reads, it only maintains "sequential consistency": in every session you observe all events in order but possibly with some delay. If you perform write in one session, then notify different part of code and it will do read in another session, that read may not see the already performed write.

Every ReplicatedMergeTree table is using only one ZooKeeper session. But if several ReplicatedMergeTree tables are using different ZooKeeper sessions, some queries like ATTACH PARTITION FROM may have strange effects (but it's unclear to me if real issues existed).

Also the code was incorrectly comparing if configuration is changed. It was comparing configurations after shuffle of hosts was done. So, almost everytime configuration is considered different and a new ZooKeeper session was established.

@alexey-milovidov alexey-milovidov merged commit b8fba76 into master Feb 27, 2021
@alexey-milovidov alexey-milovidov deleted the fix_zookeeper_update branch February 27, 2021 22:57
azat added a commit to azat/ClickHouse that referenced this pull request Feb 28, 2021
alesapin added a commit that referenced this pull request Mar 2, 2021
Backport #21264 to 21.2: Fix several bugs with ZooKeeper client
alesapin added a commit that referenced this pull request Mar 3, 2021
…d8a04a04b837948fe17e00bea23980

Cherry pick #21264 to 20.12: Fix several bugs with ZooKeeper client
alesapin added a commit that referenced this pull request Mar 3, 2021
…8a04a04b837948fe17e00bea23980

Cherry pick #21264 to 21.1: Fix several bugs with ZooKeeper client
alesapin added a commit that referenced this pull request Mar 9, 2021
Backport #21264 to 21.1: Fix several bugs with ZooKeeper client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants