| 760 | } |
| 761 | |
| 762 | bool DatabaseReplicated::looksLikeReplicatedDatabasePath(const ZooKeeperPtr & current_zookeeper, const String & path) |
| 763 | { |
| 764 | Coordination::Stat stat; |
| 765 | String maybe_database_mark; |
| 766 | if (!current_zookeeper->tryGet(path, maybe_database_mark, &stat)) |
| 767 | return false; |
| 768 | if (maybe_database_mark.starts_with(REPLICATED_DATABASE_MARK)) |
| 769 | return true; |
| 770 | if (!maybe_database_mark.empty()) |
| 771 | return false; |
| 772 | |
| 773 | /// Old versions did not have REPLICATED_DATABASE_MARK. Check specific nodes exist and add mark. |
| 774 | Coordination::Requests ops; |
| 775 | ops.emplace_back(zkutil::makeCheckRequest(path + "/log", -1)); |
| 776 | ops.emplace_back(zkutil::makeCheckRequest(path + "/replicas", -1)); |
| 777 | ops.emplace_back(zkutil::makeCheckRequest(path + "/counter", -1)); |
| 778 | ops.emplace_back(zkutil::makeCheckRequest(path + "/metadata", -1)); |
| 779 | ops.emplace_back(zkutil::makeCheckRequest(path + "/max_log_ptr", -1)); |
| 780 | ops.emplace_back(zkutil::makeCheckRequest(path + "/logs_to_keep", -1)); |
| 781 | ops.emplace_back(zkutil::makeSetRequest(path, REPLICATED_DATABASE_MARK, stat.version)); |
| 782 | Coordination::Responses responses; |
| 783 | auto res = current_zookeeper->tryMulti(ops, responses); |
| 784 | if (res == Coordination::Error::ZOK) |
| 785 | return true; |
| 786 | |
| 787 | /// Recheck database mark (just in case of concurrent update). |
| 788 | if (!current_zookeeper->tryGet(path, maybe_database_mark, &stat)) |
| 789 | return false; |
| 790 | |
| 791 | return maybe_database_mark.starts_with(REPLICATED_DATABASE_MARK); |
| 792 | } |
| 793 | |
| 794 | void DatabaseReplicated::createEmptyLogEntry(const ZooKeeperPtr & current_zookeeper) |
| 795 | { |
nothing calls this directly
no test coverage detected