github-actions[bot] commented on code in PR #62661:
URL: https://github.com/apache/doris/pull/62661#discussion_r3371541935


##########
be/src/exec/sink/writer/vtablet_writer.cpp:
##########
@@ -657,6 +670,37 @@ void VNodeChannel::_open_internal(bool is_incremental) {
     request->set_txn_expiration(_parent->_txn_expiration);
     request->set_write_file_cache(_parent->_write_file_cache);
 
+    if (_parent->_tablet_finder->is_adaptive_random_bucket()) {
+        std::unordered_map<int64_t, std::vector<int64_t>> 
partition_to_ordered_tablets;
+        for (const auto& tablet : _all_tablets) {
+            
partition_to_ordered_tablets[tablet.partition_id].push_back(tablet.tablet_id);
+        }
+        std::unordered_map<int64_t, const std::vector<int32_t>*> 
partition_to_bucket_seqs;
+        for (const auto* part : _parent->_vpartition->get_partitions()) {
+            if (!part->local_bucket_seqs.empty()) {
+                partition_to_bucket_seqs.emplace(part->id, 
&part->local_bucket_seqs);
+            }
+        }
+        for (const auto& [partition_id, ordered_tablets] : 
partition_to_ordered_tablets) {
+            auto* random_bucket_partition = 
request->add_random_bucket_partitions();
+            random_bucket_partition->set_partition_id(partition_id);
+            auto bucket_seqs_it = partition_to_bucket_seqs.find(partition_id);
+            if (bucket_seqs_it != partition_to_bucket_seqs.end()) {
+                for (auto bucket_seq : *bucket_seqs_it->second) {
+                    CHECK(bucket_seq >= 0 && bucket_seq < 
cast_set<int32_t>(ordered_tablets.size()))
+                            << "invalid local bucket seq, load_id=" << 
_parent->_load_id

Review Comment:
   This treats `local_bucket_seqs` as indexes into `ordered_tablets`, but 
`ordered_tablets` is built from this `VNodeChannel`'s `_all_tablets`, not from 
the partition's full bucket array. In single-replica or otherwise sparse 
placement, a BE-local channel only contains the buckets hosted on that BE, 
while `local_bucket_seqs` still contains global bucket numbers. For example, if 
this BE owns global buckets `[2, 5]`, `_all_tablets` has two entries but the 
first `bucket_seq` is `2`, so this `CHECK` fails; if the vector happened to be 
longer but sparse, it would pick the wrong tablet. The open request should map 
global bucket seqs against the full partition tablet list, or build a 
`bucket_seq -> tablet_id` map before filtering to the selected local sequence.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to