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

*: Refine the error message when schema mismatch in ExchangeReceiver #9744

Merged
merged 2 commits into from
Dec 27, 2024

Conversation

JaySon-Huang
Copy link
Contributor

@JaySon-Huang JaySon-Huang commented Dec 25, 2024

What problem does this PR solve?

Issue Number: ref #9673

Problem Summary:

What is changed and how it works?


Changes:

  • Refine the error message when storage.format_version is invalid
  • Refine the error message with keyspace_id, table_id, page_id, meta_version when restoring segment from disk
  • Refine the error message with exectuor name when exchange receiver meet unexpected data type

After this PR:

If we set a illegal storage.format_version

[2024/12/26 18:35:35.117 +08:00] [ERROR] [<unknown>] ["DB::Exception: Illegal format_version value: 9"] [source=Application] [thread_id=1]

If we meet unexpected data type when restarting tiflash

[2024/12/26 23:27:43.778 +08:00] [ERROR] [Exception.cpp:91] ["Storage inited fail, keyspace=4294967295 table_id=127: Code: 50, e.displayText() = DB::Exception: Unknown data type family: StringV2: file_page_id=14494 meta_version=0: while restoreSegment, segment_id=7997 ident=keyspace=4294967295 table_id=127: ...

If some tiflash is upgrade to use the new string serde format, while some tiflash is not

tidb> select
->     l_returnflag,
->     l_linestatus,
->     sum(l_quantity) as sum_qty,
->     sum(l_extendedprice) as sum_base_price,
->     sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
->     sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
->     avg(l_quantity) as avg_qty,
->     avg(l_extendedprice) as avg_price,
->     avg(l_discount) as avg_disc,
->     count(*) as count_order
-> from
->     lineitem
-> where
->     l_shipdate <= '1992-1-31'
-> group by
->     l_returnflag,
->     l_linestatus
-> order by
->     l_returnflag,
->     l_linestatus;
(1105, 'other error for mpp stream: Code: 49, e.displayText() = DB::Exception: CHBlockChunkCodecV1 schema mismatch at column 11, expected String, actual StringV2: MPP<gather_id:1, query_ts:1735122411743666484, local_query_id:2, server_id:1851, start_ts:454851929482461196,task_id:4> ExchangeReceiver_52, e.what() = DB::Exception,')

-- the plan
+--------------------------------------+-----------+--------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                   | estRows   | task         | access object  | operator info                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
+--------------------------------------+-----------+--------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Sort_6                               | 1.00      | root         |                | test.lineitem.l_returnflag, test.lineitem.l_linestatus                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| └─TableReader_54                     | 1.00      | root         |                | MppVersion: 2, data:ExchangeSender_53                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
|   └─ExchangeSender_53                | 1.00      | mpp[tiflash] |                | ExchangeType: PassThrough                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
|     └─Projection_9                   | 1.00      | mpp[tiflash] |                | test.lineitem.l_returnflag, test.lineitem.l_linestatus, Column#18, Column#19, Column#20, Column#21, Column#22, Column#23, Column#24, Column#25                                                                                                                                                                                                                                                                                                                                                                       |
|       └─Projection_49                | 1.00      | mpp[tiflash] |                | Column#18, Column#19, Column#20, Column#21, div(Column#22, cast(case(eq(Column#74, 0), 1, Column#74), decimal(20,0) BINARY))->Column#22, div(Column#23, cast(case(eq(Column#75, 0), 1, Column#75), decimal(20,0) BINARY))->Column#23, div(Column#24, cast(case(eq(Column#76, 0), 1, Column#76), decimal(20,0) BINARY))->Column#24, Column#25, test.lineitem.l_returnflag, test.lineitem.l_linestatus                                                                                                                 |
|         └─HashAgg_50                 | 1.00      | mpp[tiflash] |                | group by:test.lineitem.l_linestatus, test.lineitem.l_returnflag, funcs:sum(Column#77)->Column#18, funcs:sum(Column#78)->Column#19, funcs:sum(Column#79)->Column#20, funcs:sum(Column#80)->Column#21, funcs:sum(Column#81)->Column#74, funcs:sum(Column#82)->Column#22, funcs:sum(Column#83)->Column#75, funcs:sum(Column#84)->Column#23, funcs:sum(Column#85)->Column#76, funcs:sum(Column#86)->Column#24, funcs:sum(Column#87)->Column#25, funcs:firstrow(test.lineitem.l_returnflag)->test.lineitem.l_returnfla... |
|           └─ExchangeReceiver_52      | 1.00      | mpp[tiflash] |                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|             └─ExchangeSender_51      | 1.00      | mpp[tiflash] |                | ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: test.lineitem.l_returnflag, collate: utf8mb4_bin], [name: test.lineitem.l_linestatus, collate: utf8mb4_bin]                                                                                                                                                                                                                                                                                                                                        |
|               └─HashAgg_47           | 1.00      | mpp[tiflash] |                | group by:Column#100, Column#101, funcs:sum(Column#90)->Column#77, funcs:sum(Column#91)->Column#78, funcs:sum(Column#92)->Column#79, funcs:sum(Column#93)->Column#80, funcs:count(Column#94)->Column#81, funcs:sum(Column#95)->Column#82, funcs:count(Column#96)->Column#83, funcs:sum(Column#97)->Column#84, funcs:count(Column#98)->Column#85, funcs:sum(Column#99)->Column#86, funcs:count(1)->Column#87                                                                                                           |
|                 └─Projection_57      | 763070.18 | mpp[tiflash] |                | test.lineitem.l_quantity->Column#90, test.lineitem.l_extendedprice->Column#91, mul(test.lineitem.l_extendedprice, minus(1, test.lineitem.l_discount))->Column#92, mul(mul(test.lineitem.l_extendedprice, minus(1, test.lineitem.l_discount)), plus(1, test.lineitem.l_tax))->Column#93, test.lineitem.l_quantity->Column#94, test.lineitem.l_quantity->Column#95, test.lineitem.l_extendedprice->Column#96, test.lineitem.l_extendedprice->Column#97, test.lineitem.l_discount->Column#98, test.lineitem.l_discou... |
|                   └─TableFullScan_35 | 763070.18 | mpp[tiflash] | table:lineitem | pushed down filter:le(test.lineitem.l_shipdate, 1992-01-31 00:00:00.000000), keep order:false                                                                                                                                                                                                                                                                                                                                                                                                                        |
+--------------------------------------+-----------+--------------+----------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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

None

Signed-off-by: JaySon-Huang <[email protected]>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed do-not-merge/needs-linked-issue labels Dec 25, 2024
bool eof;
String error_msg;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define error_msg after eof so that meet_error and eof can share the same padding and minimal the struct size of ExchangeReceiverResult

@JaySon-Huang JaySon-Huang changed the title [WIP]mpp: Refine the error message when schema mismatch in ExchangeReceiver *: Refine the error message when schema mismatch in ExchangeReceiver Dec 27, 2024
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 27, 2024
Comment on lines +55 to +59
catch (DB::Exception & e)
{
e.addMessage(fmt::format("file_page_id={} meta_version={}", file_page_id, meta_version));
e.rethrow();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the Exception come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when trying to use an old version tiflash binary but load new data type

[2024/12/26 23:27:43.778 +08:00] [ERROR] [Exception.cpp:91] ["Storage inited fail, keyspace=4294967295 table_id=127: Code: 50, e.displayText() = DB::Exception: Unknown data type family: StringV2: file_page_id=14494 meta_version=0: while restoreSegment, segment_id=7997 ident=keyspace=4294967295 table_id=127: 
  0x55a0533503d3    StackTrace::StackTrace() [tiflash+35009491]
                    dbms/src/Common/StackTrace.cpp:23
  0x55a05334daa6    DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, int) [tiflash+34998950]
                    dbms/src/Common/Exception.h:46
  0x55a058b076db    DB::DataTypeFactory::get(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::shared_ptr<DB::IAST> const&) const [tiflash+126985947]
                    dbms/src/DataTypes/DataTypeFactory.cpp:119
  0x55a058b0718b    DB::DataTypeFactory::get(std::__1::shared_ptr<DB::IAST> const&) const [tiflash+126984587]
                    dbms/src/DataTypes/DataTypeFactory.cpp:87
  0x55a058b0740a    DB::DataTypeFactory::getOrSet(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) [tiflash+126985226]
                    dbms/src/DataTypes/DataTypeFactory.cpp:56
  0x55a0588d4228    DB::DM::ColumnStat::mergeFromProto(dtpb::ColumnStat const&) [tiflash+124678696]
                    dbms/src/Storages/DeltaMerge/File/ColumnStat.h:81
  0x55a0588d0f90    DB::DM::DMFileMetaV2::parseExtendColumnStat(std::__1::basic_string_view<char, std::__1::char_traits<char>>) [tiflash+124665744]
                    dbms/src/Storages/DeltaMerge/File/DMFileMetaV2.cpp:127
  0x55a0588d04b3    DB::DM::DMFileMetaV2::parse(std::__1::basic_string_view<char, std::__1::char_traits<char>>) [tiflash+124662963]
                    dbms/src/Storages/DeltaMerge/File/DMFileMetaV2.cpp:86
  0x55a0588d2771    DB::DM::DMFileMetaV2::read(std::__1::shared_ptr<DB::FileProvider> const&, DB::DM::DMFileMeta::ReadMode const&) [tiflash+124671857]
                    dbms/src/Storages/DeltaMerge/File/DMFileMetaV2.cpp:292
  0x55a0588af57e    DB::DM::DMFile::restore(std::__1::shared_ptr<DB::FileProvider> const&, unsigned long, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, DB::DM::DMFileMeta::ReadMode const&, unsigned long, unsigned int) [tiflash+124527998]
                    dbms/src/Storages/DeltaMerge/File/DMFile.cpp:0
  0x55a058862b25    DB::DM::restoreDMFileFromLocal(DB::DM::DMContext const&, unsigned long, unsigned long) [tiflash+124214053]
                    dbms/src/Storages/DeltaMerge/RestoreDMFile.cpp:72
  0x55a058859601    DB::DM::StableValueSpace::restore(DB::DM::DMContext&, DB::ReadBuffer&, unsigned long) [tiflash+124175873]
                    dbms/src/Storages/DeltaMerge/StableValueSpace.cpp:197
  0x55a058859456    DB::DM::StableValueSpace::restore(DB::DM::DMContext&, unsigned long) [tiflash+124175446]
                    dbms/src/Storages/DeltaMerge/StableValueSpace.cpp:182
  0x55a05879d494    DB::DM::Segment::restoreSegment(std::__1::shared_ptr<DB::Logger> const&, DB::DM::DMContext&, unsigned long) [tiflash+123405460]
                    dbms/src/Storages/DeltaMerge/Segment.cpp:429
  0x55a058732c07    std::__1::__function::__func<DB::DM::DeltaMergeStore::DeltaMergeStore(DB::Context&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, unsigned int, long, long, bool, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine>> const&, DB::DM::ColumnDefine const&, bool, unsigned long, std::__1::shared_ptr<std::__1::vector<DB::DM::LocalIndexInfo, std::__1::allocator<DB::DM::LocalIndexInfo>>>, DB::DM::DeltaMergeStore::Settings const&, DB::ThreadPoolImpl<DB::ThreadFromGlobalPoolImpl<false>>*)::$_1, std::__1::allocator<DB::DM::DeltaMergeStore::DeltaMergeStore(DB::Context&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&, unsigned int, long, long, bool, std::__1::vector<DB::DM::ColumnDefine, std::__1::allocator<DB::DM::ColumnDefine>> const&, DB::DM::ColumnDefine const&, bool, unsigned long, std::__1::shared_ptr<std::__1::vector<DB::DM::LocalIndexInfo, std::__1::allocator<DB::DM::LocalIndexInfo>>>, DB::DM::DeltaMergeStore::Settings const&, DB::ThreadPoolImpl<DB::ThreadFromGlobalPoolImpl<false>>*)::$_1>, void ()>::operator()() [tiflash+122969095]
                    dbms/src/Storages/DeltaMerge/DeltaMergeStore.cpp:295
  0x55a0534088f5    std::__1::packaged_task<void ()>::operator()() [tiflash+35764469]
                    /DATA/disk1/ra_common/tiflash-env-17/sysroot/bin/../include/c++/v1/future:1891
  0x55a053406e05    DB::ThreadPoolImpl<DB::ThreadFromGlobalPoolImpl<false>>::worker(std::__1::__list_iterator<DB::ThreadFromGlobalPoolImpl<false>, void*>) [tiflash+35757573]
                    /DATA/disk1/ra_common/tiflash-env-17/sysroot/bin/../include/c++/v1/__functional/function.h:517
  0x55a053409723    std::__1::__function::__func<DB::ThreadFromGlobalPoolImpl<false>::ThreadFromGlobalPoolImpl<void DB::ThreadPoolImpl<DB::ThreadFromGlobalPoolImpl<false>>::scheduleImpl<void>(std::__1::function<void ()>, long, std::__1::optional<unsigned long>, bool)::'lambda0'()>(void&&)::'lambda'(), std::__1::allocator<DB::ThreadFromGlobalPoolImpl<false>::ThreadFromGlobalPoolImpl<void DB::ThreadPoolImpl<DB::ThreadFromGlobalPoolImpl<false>>::scheduleImpl<void>(std::__1::function<void ()>, long, std::__1::optional<unsigned long>, bool)::'lambda0'()>(void&&)::'lambda'()>, void ()>::operator()() [tiflash+35768099]
                    dbms/src/Common/UniThreadPool.cpp:167
  0x55a0534055f5    DB::ThreadPoolImpl<std::__1::thread>::worker(std::__1::__list_iterator<std::__1::thread, void*>) [tiflash+35751413]
                    /DATA/disk1/ra_common/tiflash-env-17/sysroot/bin/../include/c++/v1/__functional/function.h:517
  0x55a053407cf5    void* std::__1::__thread_proxy[abi:ue170006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void DB::ThreadPoolImpl<std::__1::thread>::scheduleImpl<void>(std::__1::function<void ()>, long, std::__1::optional<unsigned long>, bool)::'lambda0'()>>(void*) [tiflash+35761397]
                    dbms/src/Common/UniThreadPool.cpp:167
  0x7fc92f140802    start_thread [libc.so.6+653314]
  0x7fc92f0e0450    clone3 [libc.so.6+259152]

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 27, 2024
Copy link
Contributor

ti-chi-bot bot commented Dec 27, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JinheLin, 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 [JinheLin,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 added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 27, 2024
Copy link
Contributor

ti-chi-bot bot commented Dec 27, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-12-27 03:53:29.632413407 +0000 UTC m=+63344.988417947: ☑️ agreed by JinheLin.
  • 2024-12-27 03:58:12.548458553 +0000 UTC m=+63627.904463093: ☑️ agreed by Lloyd-Pottiger.

@ti-chi-bot ti-chi-bot bot merged commit f0faa0c into pingcap:master Dec 27, 2024
5 checks passed
@JaySon-Huang JaySon-Huang deleted the refine_schema_mismatch branch December 27, 2024 06:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants