Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client-c: Add retry for getting TSO from PD (#8571) #8741

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #8571

What problem does this PR solve?

Issue Number: close #8323, close #8504

Problem Summary:

What is changed and how it works?

  • Retry when fetching tso from PD when we need to tombstone table/database
  • Turn pingcap::Exception into DB::Exception when getting TSO timeout to make the logging contains stack trace
  • Turn pingcap::Exception into DB::Exception in KeyspaceSnapshot to make the logging contains stack trace when something wrong happens when fetching the schema info

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
tiflash> DBGInvoke enable_fail_point(force_pd_grpc_error)
-- make region apply snapshot with schema sync
mysql> alter database test set tiflash replica 1
mysql> alter database test set tiflash replica 0
mysql> alter database test set tiflash replica 1

The logging contains stack trace where `getTSO` fail.
[2024/01/31 16:35:07.060 +08:00] [FATAL] [Exception.cpp:106] ["Code: 49, e.displayText() = DB::Exception: pingcap::Exception code=GRPCErrorCode msg=force_pd_grpc_error: keyspace=4294967295 physical_table_id=497: (while preHandleSnapshot region_id=12455, index=7, term=6), e.what() = DB::Exception, Stack trace:\n\n\n  0x55aec864f5ae\tStackTrace::StackTrace() [tiflash+71198126]\n                \tdbms/src/Common/StackTrace.cpp:23\n  0x55aec863e902\tDB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int) [tiflash+71129346]\n                \tdbms/src/Common/Exception.h:46\n  0x55aed22ff256\tDB::Exception::Exception<std::__1::basic_string_view<char, std::__1::char_traits<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&>(int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string_view<char, std::__1::char_traits<char>>&&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) [tiflash+235496022]\n                \tdbms/src/Common/Exception.h:53\n  0x55aed22f5990\tDB::PDClientHelper::getTSO(std::__1::shared_ptr<pingcap::pd::IClient> const&, unsigned long) [tiflash+235456912]\n                \tdbms/src/Storages/KVStore/TiKVHelpers/PDTiKVClient.h:105\n  0x55aed22f56fc\tDB::TiDBSchemaSyncer<false, false>::createSchemaGetter(unsigned int) [tiflash+235456252]\n                \tdbms/src/TiDB/Schema/TiDBSchemaSyncer.cpp:37\n  0x55aed22f6c40\tDB::TiDBSchemaSyncer<false, false>::syncTableSchema(DB::Context&, long) [tiflash+235461696]\n                \tdbms/src/TiDB/Schema/TiDBSchemaSyncer.cpp:251\n  0x55aed0af0a48\tDB::TiDBSchemaSyncerManager::syncTableSchema(DB::Context&, unsigned int, long) [tiflash+210270792]\n                \tdbms/src/TiDB/Schema/TiDBSchemaManager.h:66\n  0x55aed2c7a285\tDB::KVStore::preHandleSSTsToDTFiles(std::__1::shared_ptr<DB::Region>, DB::SSTViewVec, unsigned long, unsigned long, DB::DM::FileConvertJobType, DB::TMTContext&) [tiflash+245437061]\n                \tdbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp:772\n  0x55aed2c78723\tDB::KVStore::preHandleSnapshotToFiles(std::__1::shared_ptr<DB::Region>, DB::SSTViewVec, unsigned long, unsigned long, std::__1::optional<unsigned long>, DB::TMTContext&) [tiflash+245430051]\n                \tdbms/src/Storages/KVStore/MultiRaft/PrehandleSnapshot.cpp:263\n  0x55aed2c492de\tPreHandleSnapshot [tiflash+245236446]\n                \tdbms/src/Storages/KVStore/FFI/ProxyFFI.cpp:680\n  0x7f8d45e1f9a6\tproxy_ffi::engine_store_helper_impls::_$LT$impl$u20$proxy_ffi..interfaces..root..DB..EngineStoreServerHelper$GT$::pre_handle_snapshot::h651197c9a059a225 [libtiflash_proxy.so+150645158]\n  0x7f8d45d8ffdd\tengine_store_ffi::core::forward_raft::snapshot::pre_handle_snapshot_impl::hc5d9838930ef3c5b [libtiflash_proxy.so+150056925]\n  0x7f8d4186db90\tengine_store_ffi::core::forward_raft::snapshot::_$LT$impl$u20$engine_store_ffi..core..forwarder..ProxyForwarder$LT$T$C$ER$GT$$GT$::pre_apply_snapshot::_$u7b$$u7b$closure$u7d$$u7d$::h83533edc3760d8fd [libtiflash_proxy.so+77564816]\n  0x7f8d43156a22\t_$LT$core..future..from_generator..GenFuture$LT$T$GT$$u20$as$u20$core..future..future..Future$GT$::poll::h38ca8f7477536ed0 [libtiflash_proxy.so+103684642]\n  0x7f8d435d61c9\tyatp::task::future::RawTask$LT$F$GT$::poll::h1319886c65d7f02e [libtiflash_proxy.so+108401097]\n  0x7f8d472120de\tyatp::task::future::TaskCell::poll::hbbb766a97468e2df [libtiflash_proxy.so+171561182]\n  0x7f8d47212e94\t_$LT$yatp..task..future..Runner$u20$as$u20$yatp..pool..runner..Runner$GT$::handle::h3c329648fd40d6ed [libtiflash_proxy.so+171564692]\n  0x7f8d4720d563\tyatp::pool::worker::WorkerThread$LT$T$C$R$GT$::run::hd8dbb26e2d7bf247 [libtiflash_proxy.so+171541859]\n  0x7f8d471d427d\tyatp::pool::builder::LazyBuilder$LT$T$GT$::build::_$u7b$$u7b$closure$u7d$$u7d$::h514ea08a6145fb22 [libtiflash_proxy.so+171307645]\n  0x7f8d471c8a0c\tstd::sys_common::backtrace::__rust_begin_short_backtrace::h077f138196384345 [libtiflash_proxy.so+171260428]\n  0x7f8d4720043d\tstd::thread::Builder::spawn_unchecked_::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hb9a4f6f6f0cd6ab0 [libtiflash_proxy.so+171488317]\n  0x7f8d471d73d1\t_$LT$core..panic..unwind_safe..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::h5b4b03ee84d96aa4 [libtiflash_proxy.so+171320273]\n  0x7f8d47200666\tstd::panicking::try::do_call::h825e38935db99a94 [libtiflash_proxy.so+171488870]\n  0x7f8d4721392b\t__rust_try [libtiflash_proxy.so+171567403]\n  0x7f8d4720058f\tstd::panicking::try::hcf8a41405db4db12 [libtiflash_proxy.so+171488655]\n  0x7f8d471fea41\tstd::panic::catch_unwind::h96e08252e1e218de [libtiflash_proxy.so+171481665]\n  0x7f8d4720020a\tstd::thread::Builder::spawn_unchecked_::_$u7b$$u7b$closure$u7d$$u7d$::h1aaaf3ff102ab795 [libtiflash_proxy.so+171487754]\n  0x7f8d47201fd7\tcore::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::h9122f2f9f9bffe80 [libtiflash_proxy.so+171495383]\n  0x7f8d4875a023\tstd::sys::unix::thread::Thread::new::thread_start::hd2791a9cabec1fda [libtiflash_proxy.so+193876003]\n                \t/rustc/96ddd32c4bfb1d78f0cd03eb068b1710a8cebeef/library/std/src/sys/unix/thread.rs:108\n  0x7f8d3cb3e802\tstart_thread [libc.so.6+653314]\n  0x7f8d3cade450\tclone3 [libc.so.6+259152]"] [source="DB::RawCppPtr DB::PreHandleSnapshot(DB::EngineStoreServerWrap *, DB::BaseBuffView, uint64_t, DB::SSTViewVec, uint64_t, uint64_t)"] [thread_id=401]
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Add retry for getting tso from PD when the connection is unstable

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jan 31, 2024
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-7.1 This PR is cherry-picked to release-7.1 from a source PR. labels Jan 31, 2024
@ti-chi-bot ti-chi-bot bot added do-not-merge/cherry-pick-not-approved size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 31, 2024
Signed-off-by: JaySon-Huang <tshent@qq.com>
@JaySon-Huang JaySon-Huang force-pushed the cherry-pick-8571-to-release-7.1 branch from 94bc151 to 26d80a8 Compare January 31, 2024 15:15
@JaySon-Huang
Copy link
Contributor

/run-all-tests

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jan 31, 2024
@ti-chi-bot ti-chi-bot added the cherry-pick-approved Cherry pick PR approved by release team. label Feb 1, 2024
@ti-chi-bot ti-chi-bot bot added the lgtm label Feb 1, 2024
Copy link
Contributor

ti-chi-bot bot commented Feb 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JaySon-Huang, Lloyd-Pottiger

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [JaySon-Huang,Lloyd-Pottiger]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Feb 1, 2024
Copy link
Contributor

ti-chi-bot bot commented Feb 1, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-31 15:45:10.318377364 +0000 UTC m=+1580351.882675069: ☑️ agreed by JaySon-Huang.
  • 2024-02-01 01:36:43.90555783 +0000 UTC m=+1615845.469855529: ☑️ agreed by Lloyd-Pottiger.

@ti-chi-bot ti-chi-bot bot merged commit b7b6d00 into pingcap:release-7.1 Feb 1, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-7.1 This PR is cherry-picked to release-7.1 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants