From 67309faca5f3472db0076a164c0e99cf09f9185c Mon Sep 17 00:00:00 2001 From: Calvin Neo Date: Tue, 10 Mar 2026 16:28:45 +0800 Subject: [PATCH 1/6] a Signed-off-by: Calvin Neo --- .../Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp | 1 + .../Storages/KVStore/tests/gtest_new_kvstore.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp index 4ce88ec3555..7a9de4d063b 100644 --- a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp +++ b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp @@ -183,6 +183,7 @@ EngineStoreApplyRes KVStore::handleAdminRaftCmd( case raft_cmdpb::AdminCmdType::PrepareFlashback: case raft_cmdpb::AdminCmdType::FinishFlashback: case raft_cmdpb::AdminCmdType::BatchSwitchWitness: + case raft_cmdpb::AdminCmdType::TransferLeader: return handleUselessAdminRaftCmd(type, curr_region_id, index, term, tmt); default: break; diff --git a/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp b/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp index aaa1c1f0bd9..e7fd344bc3a 100644 --- a/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp +++ b/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp @@ -393,11 +393,23 @@ try ctx.getTMTContext()), EngineStoreApplyRes::None); + request.set_cmd_type(::raft_cmdpb::AdminCmdType::TransferLeader); + response = response2; + ASSERT_EQ( + kvs.handleAdminRaftCmd( + raft_cmdpb::AdminRequest{request}, + std::move(response), + region_id, + 26, + 6, + ctx.getTMTContext()), + EngineStoreApplyRes::None); + { kvs.debugGetConfigMut().debugSetCompactLogConfig(0, 0, 0, 0); request.set_cmd_type(::raft_cmdpb::AdminCmdType::CompactLog); ASSERT_EQ( - kvs.handleAdminRaftCmd(std::move(request), std::move(response2), region_id, 26, 6, ctx.getTMTContext()), + kvs.handleAdminRaftCmd(std::move(request), std::move(response2), region_id, 27, 6, ctx.getTMTContext()), EngineStoreApplyRes::Persist); } } From f27e9054d76e6958060c7644466958fad934c905 Mon Sep 17 00:00:00 2001 From: Calvin Neo Date: Tue, 10 Mar 2026 16:36:53 +0800 Subject: [PATCH 2/6] a Signed-off-by: Calvin Neo --- dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp | 2 ++ dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp index 7a9de4d063b..a220c0d5efa 100644 --- a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp +++ b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp @@ -183,6 +183,8 @@ EngineStoreApplyRes KVStore::handleAdminRaftCmd( case raft_cmdpb::AdminCmdType::PrepareFlashback: case raft_cmdpb::AdminCmdType::FinishFlashback: case raft_cmdpb::AdminCmdType::BatchSwitchWitness: + // Initialy, with tiflash-proxy, TransferLeader will be rewrited into empty write cmd, + // so this case is not possible. However, nextgen-proxy implements in another way, so we have to workaround here. case raft_cmdpb::AdminCmdType::TransferLeader: return handleUselessAdminRaftCmd(type, curr_region_id, index, term, tmt); default: diff --git a/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp b/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp index e7fd344bc3a..a93bda58838 100644 --- a/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp +++ b/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp @@ -392,7 +392,7 @@ try 6, ctx.getTMTContext()), EngineStoreApplyRes::None); - + request.set_cmd_type(::raft_cmdpb::AdminCmdType::TransferLeader); response = response2; ASSERT_EQ( From 7e1aa7d88697b20d3e9cbe3fea4bfea554a45866 Mon Sep 17 00:00:00 2001 From: Calvin Neo Date: Tue, 10 Mar 2026 17:08:14 +0800 Subject: [PATCH 3/6] a Signed-off-by: Calvin Neo --- dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp index a220c0d5efa..b01d16c2749 100644 --- a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp +++ b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp @@ -186,6 +186,7 @@ EngineStoreApplyRes KVStore::handleAdminRaftCmd( // Initialy, with tiflash-proxy, TransferLeader will be rewrited into empty write cmd, // so this case is not possible. However, nextgen-proxy implements in another way, so we have to workaround here. case raft_cmdpb::AdminCmdType::TransferLeader: + case raft_cmdpb::AdminCmdType::UpdateGcPeer: return handleUselessAdminRaftCmd(type, curr_region_id, index, term, tmt); default: break; From 3140a4015500ea5c15b300d74466e46bcffee951 Mon Sep 17 00:00:00 2001 From: Calvin Neo Date: Tue, 10 Mar 2026 18:04:41 +0800 Subject: [PATCH 4/6] Update dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp Co-authored-by: JaySon --- dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp index b01d16c2749..2683a53c70c 100644 --- a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp +++ b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp @@ -184,7 +184,7 @@ EngineStoreApplyRes KVStore::handleAdminRaftCmd( case raft_cmdpb::AdminCmdType::FinishFlashback: case raft_cmdpb::AdminCmdType::BatchSwitchWitness: // Initialy, with tiflash-proxy, TransferLeader will be rewrited into empty write cmd, - // so this case is not possible. However, nextgen-proxy implements in another way, so we have to workaround here. + // so this case is not possible. However, tiflash-proxy-next-gen will dispatch the TransferLeader to tiflash, so we have to workaround here. case raft_cmdpb::AdminCmdType::TransferLeader: case raft_cmdpb::AdminCmdType::UpdateGcPeer: return handleUselessAdminRaftCmd(type, curr_region_id, index, term, tmt); From 2835e49f530becec43f056e7b2c2e9611547e8a5 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Tue, 10 Mar 2026 21:28:35 +0800 Subject: [PATCH 5/6] Update proxy to downgrade logging level Signed-off-by: JaySon-Huang --- contrib/tiflash-proxy | 2 +- contrib/tiflash-proxy-next-gen | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/tiflash-proxy b/contrib/tiflash-proxy index 768e3440b32..6be9eeae33e 160000 --- a/contrib/tiflash-proxy +++ b/contrib/tiflash-proxy @@ -1 +1 @@ -Subproject commit 768e3440b32dafe94d326b298e64a1165ea7ec0e +Subproject commit 6be9eeae33e8aa90af99ed3458f21d6e9b5d7e18 diff --git a/contrib/tiflash-proxy-next-gen b/contrib/tiflash-proxy-next-gen index 10e55dcd086..113679b2168 160000 --- a/contrib/tiflash-proxy-next-gen +++ b/contrib/tiflash-proxy-next-gen @@ -1 +1 @@ -Subproject commit 10e55dcd0867f44cc3503b2f23f477a034c37840 +Subproject commit 113679b2168620b65b5db532312e66c39f25e755 From 0fd63d0ab36cddc89a147a5c5a0e24760bdcc8ad Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Tue, 10 Mar 2026 21:30:37 +0800 Subject: [PATCH 6/6] Format codes Signed-off-by: JaySon-Huang --- dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp b/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp index a93bda58838..e7fd344bc3a 100644 --- a/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp +++ b/dbms/src/Storages/KVStore/tests/gtest_new_kvstore.cpp @@ -392,7 +392,7 @@ try 6, ctx.getTMTContext()), EngineStoreApplyRes::None); - + request.set_cmd_type(::raft_cmdpb::AdminCmdType::TransferLeader); response = response2; ASSERT_EQ(