Skip to content

Fix race conditions in CREATE/DROP of different replicas of ReplicatedMergeTree#11592

Merged
alexey-milovidov merged 4 commits intomasterfrom
replicated-merge-tree-create-drop-race-garbage
Jun 11, 2020
Merged

Fix race conditions in CREATE/DROP of different replicas of ReplicatedMergeTree#11592
alexey-milovidov merged 4 commits intomasterfrom
replicated-merge-tree-create-drop-race-garbage

Conversation

@alexey-milovidov
Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov commented Jun 11, 2020

Changelog category (leave one):

  • Bug Fix

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix race conditions in CREATE/DROP of different replicas of ReplicatedMergeTree. Continue to work if the table was not removed completely from ZooKeeper or not created successfully. This fixes #11432.

Detailed description / Documentation draft:
See https://clickhouse-test-reports.s3.yandex.net/11580/e2c6d090192d870edffc40e40deeb4c14417e5be/functional_stateless_tests_(thread)/test_run.txt.out.log

@alexey-milovidov alexey-milovidov added testing Special issue with list of bugs found by CI pr-no-backport labels Jun 11, 2020
@blinkov blinkov added the pr-bugfix Pull request with bugfix, not backported by default label Jun 11, 2020
@alesapin alesapin self-assigned this Jun 11, 2020
@alexey-milovidov
Copy link
Copy Markdown
Member Author

PVS Ok.

Copy link
Copy Markdown
Member

@alesapin alesapin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's quite a complicated solution, but I cannot propose something simpler. It will not work between concurrent drop/create between different versions but it's OK.

else if (code == Coordination::ZNOTEMPTY)
{
throw Exception(fmt::format(
"The old table was not completely removed from ZooKeeper, {} still exists and may contain some garbage.", zookeeper_path), ErrorCodes::TABLE_WAS_NOT_DROPPED);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it's possible? We create both zookeeper_path and it's content in a single transaction bellow. It can be empty or doesn't exist.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it's not possible. And it does not reproduce in test.
I will change to code to LOGICAL_ERROR.

ops.emplace_back(zkutil::makeCreateRequest(zookeeper_path, "", zkutil::CreateMode::Persistent));

/// Check that the table is not being dropped right now.
ops.emplace_back(zkutil::makeCreateRequest(zookeeper_path + "/dropped", "", zkutil::CreateMode::Persistent));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting way to check that node doesn't exist)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and I did not invent it :) It's already used in other places in code.

@alexey-milovidov alexey-milovidov mentioned this pull request Jun 11, 2020
16 tasks
@alexey-milovidov alexey-milovidov merged commit 89df991 into master Jun 11, 2020
@alexey-milovidov alexey-milovidov deleted the replicated-merge-tree-create-drop-race-garbage branch June 11, 2020 14:11
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 pr-no-backport testing Special issue with list of bugs found by CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception: Directory for table data already exists.

4 participants