diff --git a/contrib/tiflash-proxy b/contrib/tiflash-proxy index 0ea7365e654..bb6ebf69f68 160000 --- a/contrib/tiflash-proxy +++ b/contrib/tiflash-proxy @@ -1 +1 @@ -Subproject commit 0ea7365e654321f45f5587e93d22b89863bdae1c +Subproject commit bb6ebf69f68a4cd7b159468bbc3825cd2d3fd69b diff --git a/dbms/src/Storages/KVStore/tests/gtest_async_tasks.cpp b/dbms/src/Storages/KVStore/tests/gtest_async_tasks.cpp index 01addf6e22d..d15e0695828 100644 --- a/dbms/src/Storages/KVStore/tests/gtest_async_tasks.cpp +++ b/dbms/src/Storages/KVStore/tests/gtest_async_tasks.cpp @@ -254,7 +254,7 @@ try auto async_tasks = std::make_unique(1, 1, 2); int total = 5; - int max_steps = 10; + int max_steps = 15; int current_step = 0; std::vector f(total, false); std::vector s(total, false); diff --git a/dbms/src/Storages/Page/V3/Universal/UniversalWriteBatchImpl.h b/dbms/src/Storages/Page/V3/Universal/UniversalWriteBatchImpl.h index d5caf135475..a53913f51ac 100644 --- a/dbms/src/Storages/Page/V3/Universal/UniversalWriteBatchImpl.h +++ b/dbms/src/Storages/Page/V3/Universal/UniversalWriteBatchImpl.h @@ -28,6 +28,11 @@ namespace ErrorCodes extern const int LOGICAL_ERROR; } // namespace ErrorCodes +namespace tests +{ +class UniPageStorageIdTest; +} + class UniversalWriteBatch : private boost::noncopyable { private: @@ -266,6 +271,7 @@ class UniversalWriteBatch : private boost::noncopyable void merge(UniversalWriteBatch & rhs) { writes.reserve(writes.size() + rhs.writes.size()); + PS::PageStorageMemorySummary::universal_write_count.fetch_add(rhs.writes.size()); for (const auto & r : rhs.writes) { writes.emplace_back(r); @@ -276,6 +282,7 @@ class UniversalWriteBatch : private boost::noncopyable [[clang::reinitializes]] void clear() { + PS::PageStorageMemorySummary::universal_write_count.fetch_sub(writes.size()); Writes tmp; writes.swap(tmp); total_data_size = 0; @@ -302,6 +309,9 @@ class UniversalWriteBatch : private boost::noncopyable std::swap(remote_lock_disabled, o.remote_lock_disabled); } +private: + friend class UniPageStorageIdTest; + private: String prefix; Writes writes; diff --git a/dbms/src/Storages/Page/V3/Universal/tests/gtest_universal_page_storage.cpp b/dbms/src/Storages/Page/V3/Universal/tests/gtest_universal_page_storage.cpp index 3015c2d6132..1d9f7c197e2 100644 --- a/dbms/src/Storages/Page/V3/Universal/tests/gtest_universal_page_storage.cpp +++ b/dbms/src/Storages/Page/V3/Universal/tests/gtest_universal_page_storage.cpp @@ -619,6 +619,50 @@ TEST(UniPageStorageIdTest, UniversalWriteBatchMemory) ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 1); } ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 0); + { + UniversalWriteBatch wb; + wb.putPage( + UniversalPageIdFormat::toFullPageId(prefix, 0), + tag, + std::make_shared(c_buff, buf_sz), + buf_sz); + UniversalWriteBatch wb2; + wb2.merge(wb); + ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 2); + } + { + UniversalWriteBatch wb; + wb.putPage( + UniversalPageIdFormat::toFullPageId(prefix, 0), + tag, + std::make_shared(c_buff, buf_sz), + buf_sz); + wb.clear(); + ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 0); + } + { + UniversalWriteBatch wb; + wb.putPage( + UniversalPageIdFormat::toFullPageId(prefix, 0), + tag, + std::make_shared(c_buff, buf_sz), + buf_sz); + ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 1); + UniversalWriteBatch wb2; + wb.putPage( + UniversalPageIdFormat::toFullPageId(prefix, 1), + tag, + std::make_shared(c_buff, buf_sz), + buf_sz); + wb.putPage( + UniversalPageIdFormat::toFullPageId(prefix, 2), + tag, + std::make_shared(c_buff, buf_sz), + buf_sz); + ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 3); + wb.swap(wb2); + ASSERT_EQ(PageStorageMemorySummary::universal_write_count.load(), 3); + } } } // namespace PS::universal::tests