diff options
author | Geir Storli <geirst@verizonmedia.com> | 2021-06-15 15:48:42 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2021-06-15 16:00:21 +0000 |
commit | 2c710e364c2777c9abac98750f9e7f5e6ae8d3ee (patch) | |
tree | d59f64fae0dced3c59d8bd54965c918223151406 /storage | |
parent | 8ef499e16e9fb5daede071d36cb523f4d30538c0 (diff) |
Assert that the storage message has a valid bucket id for striping.
Diffstat (limited to 'storage')
-rw-r--r-- | storage/src/vespa/storage/distributor/distributor.cpp | 18 | ||||
-rw-r--r-- | storage/src/vespa/storage/distributor/distributor.h | 2 |
2 files changed, 11 insertions, 9 deletions
diff --git a/storage/src/vespa/storage/distributor/distributor.cpp b/storage/src/vespa/storage/distributor/distributor.cpp index 448cbc9809d..4e6ae90718c 100644 --- a/storage/src/vespa/storage/distributor/distributor.cpp +++ b/storage/src/vespa/storage/distributor/distributor.cpp @@ -385,19 +385,21 @@ Distributor::random_stripe_idx() } uint32_t -Distributor::stripe_of_bucket_id(const document::BucketId& bucketd_id, api::MessageType::Id msg_id) +Distributor::stripe_of_bucket_id(const document::BucketId& bucket_id, const api::StorageMessage& msg) { - if (!bucketd_id.isSet()) { - // TODO STRIPE: Messages with a non-set bucket id should be handled by the top-level distributor instead. - return 0; - } else if (bucketd_id.getUsedBits() < spi::BucketLimits::MinUsedBits) { - if (msg_id == api::MessageType::VISITOR_CREATE_ID) { + if (!bucket_id.isSet()) { + LOG(error, "Message (%s) has a bucket id (%s) that is not set. Cannot route to stripe", + msg.getSummary().c_str(), bucket_id.toString().c_str()); + } + assert(bucket_id.isSet()); + if (bucket_id.getUsedBits() < spi::BucketLimits::MinUsedBits) { + if (msg.getType().getId() == api::MessageType::VISITOR_CREATE_ID) { // This message will eventually be bounced with api::ReturnCode::WRONG_DISTRIBUTION, // so we can just route it to a random distributor stripe. return random_stripe_idx(); } } - return storage::stripe_of_bucket_key(bucketd_id.toKey(), _n_stripe_bits); + return storage::stripe_of_bucket_key(bucket_id.toKey(), _n_stripe_bits); } bool @@ -413,7 +415,7 @@ Distributor::onDown(const std::shared_ptr<api::StorageMessage>& msg) return true; } auto bucket_id = get_bucket_id_for_striping(*msg, _component); - uint32_t stripe_idx = stripe_of_bucket_id(bucket_id, msg->getType().getId()); + uint32_t stripe_idx = stripe_of_bucket_id(bucket_id, *msg); MBUS_TRACE(msg->getTrace(), 9, vespalib::make_string("Distributor::onDown(): Dispatch message to stripe %u", stripe_idx)); bool handled = _stripes[stripe_idx]->handle_or_enqueue_message(msg); diff --git a/storage/src/vespa/storage/distributor/distributor.h b/storage/src/vespa/storage/distributor/distributor.h index 831750a1c89..6f0808ad63d 100644 --- a/storage/src/vespa/storage/distributor/distributor.h +++ b/storage/src/vespa/storage/distributor/distributor.h @@ -189,7 +189,7 @@ private: [[nodiscard]] bool may_send_host_info_on_behalf_of_stripes(std::lock_guard<std::mutex>& held_lock) noexcept; uint32_t random_stripe_idx(); - uint32_t stripe_of_bucket_id(const document::BucketId& bucketd_id, api::MessageType::Id msg_id); + uint32_t stripe_of_bucket_id(const document::BucketId& bucket_id, const api::StorageMessage& msg); struct StripeScanStats { bool wants_to_send_host_info = false; |