| 1003 | } |
| 1004 | |
| 1005 | void CatalogServer::MarkPendingMetadataReset(const unique_lock<std::mutex>& lock) { |
| 1006 | DCHECK(lock.mutex() == &catalog_lock_ && lock.owns_lock()) |
| 1007 | << "Must hold catalog_lock_ to avoid concurrency with TriggerResetMetadata thread"; |
| 1008 | long current_catalog_resets; |
| 1009 | Status status = catalog_->GetNumCatalogResetStarts(¤t_catalog_resets); |
| 1010 | |
| 1011 | if (status.ok()) { |
| 1012 | min_catalog_resets_to_serve_.Store(current_catalog_resets + 1); |
| 1013 | LOG(INFO) << "Marking pending metadata reset. Min number of catalog resets to serve: " |
| 1014 | << min_catalog_resets_to_serve_.Load(); |
| 1015 | } else { |
| 1016 | /// If somehow we failed to get the number, sets a conservative value. |
| 1017 | min_catalog_resets_to_serve_.Add(1); |
| 1018 | LOG(ERROR) << "Failed to get current catalog version: " << status.GetDetail() |
| 1019 | << "Some requests might run on stale metadata."; |
| 1020 | } |
| 1021 | // Sets this after we updated min_catalog_resets_to_serve_ since the consumers check |
| 1022 | // this before read/write on num of catalog resets. The consumers are |
| 1023 | // - Requests in WaitPendingMetadataResetStarts(). Read this and num of catalog resets |
| 1024 | // in JVM. |
| 1025 | // - TriggerResetMetadata thread. Reads this and updates num of catalog resets in JVM. |
| 1026 | triggered_pending_reset_.Store(false); |
| 1027 | } |
| 1028 | |
| 1029 | [[noreturn]] void CatalogServer::TriggerResetMetadata() { |
| 1030 | while (true) { |