|
39 | 39 | #endif |
40 | 40 |
|
41 | 41 | #include <fmt/ranges.h> |
42 | | - |
| 42 | +#include <iostream> |
| 43 | +#include <Disks/DiskType.h> |
43 | 44 |
|
44 | 45 | namespace fs = std::filesystem; |
45 | 46 | namespace ProfileEvents |
@@ -520,6 +521,13 @@ StorageObjectStorageSource::ReaderHolder StorageObjectStorageSource::createReade |
520 | 521 | while (not_a_path || (query_settings.skip_empty_files && object_info->metadata->size_bytes == 0)); |
521 | 522 |
|
522 | 523 | ObjectStoragePtr storage_to_use = object_info->getObjectStorage().value_or(object_storage); |
| 524 | + |
| 525 | + std::cerr << "[WORKER createReader] object_info->getPath()=" << object_info->getPath() |
| 526 | + << " object_info->relative_path=" << object_info->relative_path |
| 527 | + << " object_info->getAbsolutePath()=" << (object_info->getAbsolutePath().has_value() ? object_info->getAbsolutePath().value() : "none") |
| 528 | + << " storage_to_use_type=" << toString(storage_to_use->getType()) |
| 529 | + << " storage_to_use_desc=" << storage_to_use->getDescription() |
| 530 | + << std::endl; |
523 | 531 |
|
524 | 532 | QueryPipelineBuilder builder; |
525 | 533 | std::shared_ptr<ISource> source; |
@@ -1317,23 +1325,60 @@ StorageObjectStorage::ObjectInfoPtr StorageObjectStorageSource::ReadTaskIterator |
1317 | 1325 | if (!raw || raw->isEmpty()) |
1318 | 1326 | return nullptr; |
1319 | 1327 |
|
1320 | | - object_info = raw->getObjectInfo(); |
| 1328 | + std::cerr << "[WORKER ReadTaskIterator::next] received raw->path=" << raw->path |
| 1329 | + << " raw->absolute_path=" << (raw->absolute_path.has_value() ? raw->absolute_path.value() : "none") |
| 1330 | + << std::endl; |
1321 | 1331 |
|
| 1332 | + object_info = raw->getObjectInfo(); |
| 1333 | + |
| 1334 | + std::cerr << "[WORKER ReadTaskIterator::next] after getObjectInfo: object_info->getPath()=" << object_info->getPath() |
| 1335 | + << " object_info->getAbsolutePath()=" << (object_info->getAbsolutePath().has_value() ? object_info->getAbsolutePath().value() : "none") |
| 1336 | + << " object_info->getObjectStorage()=" << (object_info->getObjectStorage().has_value() ? "set" : "not_set") |
| 1337 | + << std::endl; |
| 1338 | + |
| 1339 | + // The 'path' field from master is already the correctly resolved relative path. |
| 1340 | + // We should use it directly and NOT overwrite relative_path. |
| 1341 | + // Only resolve absolute_path if we need to determine which storage to use (for secondary storages). |
| 1342 | + object_info->object_storage_to_use = object_storage; |
| 1343 | + |
1322 | 1344 | if (raw->absolute_path.has_value()) |
1323 | 1345 | { |
1324 | 1346 | auto [storage_to_use, key] |
1325 | 1347 | = resolveObjectStorageForPath("", raw->absolute_path.value(), object_storage, secondary_storages, getContext()); |
1326 | 1348 |
|
1327 | | - if (!key.empty()) /// Otherwise not a valid key/path, maybe it is "retry_after_us". Store as is. |
| 1349 | + std::cerr << "[WORKER ReadTaskIterator::next] resolved absolute_path: key=" << key |
| 1350 | + << " storage_type=" << (storage_to_use ? toString(storage_to_use->getType()) : "null") |
| 1351 | + << " storage_desc=" << (storage_to_use ? storage_to_use->getDescription() : "null") |
| 1352 | + << " storage_same_as_base=" << (storage_to_use == object_storage ? "true" : "false") |
| 1353 | + << " original_relative_path=" << object_info->relative_path |
| 1354 | + << std::endl; |
| 1355 | + |
| 1356 | + if (!key.empty() && storage_to_use != object_storage) |
1328 | 1357 | { |
| 1358 | + // File is in a different storage (secondary storage), use that storage |
| 1359 | + // BUT preserve the original relative_path from master - don't overwrite it! |
1329 | 1360 | object_info->object_storage_to_use = storage_to_use; |
1330 | | - object_info->relative_path = key; |
| 1361 | + |
| 1362 | + std::cerr << "[WORKER ReadTaskIterator::next] SET: object_storage_to_use=secondary_storage" |
| 1363 | + << " relative_path=" << object_info->relative_path << " (preserved from master)" |
| 1364 | + << std::endl; |
| 1365 | + } |
| 1366 | + else |
| 1367 | + { |
| 1368 | + std::cerr << "[WORKER ReadTaskIterator::next] using default storage, relative_path=" << object_info->relative_path |
| 1369 | + << " (preserved from master)" << std::endl; |
1331 | 1370 | } |
1332 | 1371 | } |
1333 | 1372 | else |
1334 | 1373 | { |
1335 | | - object_info->object_storage_to_use = object_storage; |
| 1374 | + std::cerr << "[WORKER ReadTaskIterator::next] NO absolute_path: using default storage, relative_path=" << object_info->relative_path |
| 1375 | + << " (preserved from master)" << std::endl; |
1336 | 1376 | } |
| 1377 | + |
| 1378 | + std::cerr << "[WORKER ReadTaskIterator::next] FINAL: object_info->getPath()=" << object_info->getPath() |
| 1379 | + << " object_info->relative_path=" << object_info->relative_path |
| 1380 | + << " object_info->getObjectStorage()=" << (object_info->getObjectStorage().has_value() ? "set" : "not_set") |
| 1381 | + << std::endl; |
1337 | 1382 | } |
1338 | 1383 | else |
1339 | 1384 | { |
|
0 commit comments