|
18 | 18 |
|
19 | 19 | #include "ob_index_block_builder.h" |
20 | 20 | #include "storage/blocksstable/ob_shared_macro_block_manager.h" |
| 21 | +#include "share/ob_io_device_helper.h" |
21 | 22 |
|
22 | 23 | #ifdef OB_BUILD_SHARED_STORAGE |
23 | 24 | #include "share/compaction/ob_shared_storage_compaction_util.h" |
@@ -1579,6 +1580,22 @@ int64_t ObSSTableIndexBuilder::get_tablet_transfer_seq() const |
1579 | 1580 | return data_store_desc_.get_desc().get_tablet_transfer_seq(); |
1580 | 1581 | } |
1581 | 1582 |
|
| 1583 | +int ObSSTableIndexBuilder::fsync_block() |
| 1584 | +{ |
| 1585 | + int ret = OB_SUCCESS; |
| 1586 | + const bool in_array = roots_[0]->meta_block_info_.in_array(); |
| 1587 | + bool all_in_mem = true; |
| 1588 | + for (int64_t i = 0; i < roots_.count(); ++i) { |
| 1589 | + all_in_mem &= !roots_[i]->meta_block_info_.in_disk(); |
| 1590 | + } |
| 1591 | + if (in_array || all_in_mem) { |
| 1592 | + // do nothing |
| 1593 | + } else if (OB_FAIL(LOCAL_DEVICE_INSTANCE.fsync_block())) { |
| 1594 | + STORAGE_LOG(WARN, "fail to fsync_block", K(ret)); |
| 1595 | + } |
| 1596 | + return ret; |
| 1597 | +} |
| 1598 | + |
1582 | 1599 | int ObSSTableIndexBuilder::close(ObSSTableMergeRes &res, |
1583 | 1600 | const int64_t nested_size, |
1584 | 1601 | const int64_t nested_offset, |
@@ -1679,6 +1696,8 @@ int ObSSTableIndexBuilder::close_with_macro_seq_inner( |
1679 | 1696 | } |
1680 | 1697 | if (OB_FAIL(ret) || roots_.empty() || is_closed_) { |
1681 | 1698 | // do nothing |
| 1699 | + } else if (!GCTX.is_shared_storage_mode() && OB_FAIL(fsync_block())) { |
| 1700 | + STORAGE_LOG(WARN, "fail to fsync_block", K(ret)); |
1682 | 1701 | } else if (OB_FAIL(merge_index_tree(pre_warm_param, res, macro_seq, callback))) { |
1683 | 1702 | STORAGE_LOG(WARN, "fail to merge index tree", K(ret), KP(callback)); |
1684 | 1703 | } else if (OB_FAIL(build_meta_tree(pre_warm_param, res, ++macro_seq, callback))) { |
@@ -1810,6 +1829,8 @@ int ObSSTableIndexBuilder::rewrite_small_sstable(ObSSTableMergeRes &res) |
1810 | 1829 | container_store_desc_, roots_, macro_meta))) { |
1811 | 1830 | STORAGE_LOG(WARN, "fail to get single macro meta", K(ret)); |
1812 | 1831 | } else if (FALSE_IT(read_info.macro_block_id_ = macro_meta.val_.macro_id_)) { |
| 1832 | + } else if (!GCTX.is_shared_storage_mode() && OB_FAIL(LOCAL_DEVICE_INSTANCE.fsync_block())) { |
| 1833 | + LOG_WARN("fail to fsync_block", K(ret)); |
1813 | 1834 | } else if (OB_FAIL(ObObjectManager::async_read_object(read_info, read_handle))) { |
1814 | 1835 | STORAGE_LOG(WARN, "fail to async read macro block", K(ret), K(read_info), K(macro_meta), K(roots_[0]->last_macro_size_)); |
1815 | 1836 | } else if (OB_FAIL(read_handle.wait())) { |
@@ -1922,6 +1943,8 @@ int ObSSTableIndexBuilder::load_single_macro_block( |
1922 | 1943 | ret = OB_ALLOCATE_MEMORY_FAILED; |
1923 | 1944 | STORAGE_LOG(WARN, "failed to alloc macro read info buffer", K(ret), |
1924 | 1945 | K(read_info.size_)); |
| 1946 | + } else if (!GCTX.is_shared_storage_mode() && OB_FAIL(LOCAL_DEVICE_INSTANCE.fsync_block())) { |
| 1947 | + LOG_WARN("fail to fsync_block", K(ret)); |
1925 | 1948 | } else if (OB_FAIL(ObObjectManager::async_read_object(read_info, read_handle))) { |
1926 | 1949 | STORAGE_LOG(WARN, "fail to async read macro block", K(ret), K(read_info), K(macro_meta)); |
1927 | 1950 | } else if (OB_FAIL(read_handle.wait())) { |
|
0 commit comments