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

[fix](txn) make sub transactions visible for mow #43011

Closed
wants to merge 8 commits into from

Conversation

mymeiyi
Copy link
Contributor

@mymeiyi mymeiyi commented Oct 31, 2024

this pr is based on #41362 and #41932
The idea is when query rowsets of sub txns, calculate its delete bitmap

@doris-robot
Copy link

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR

Since 2024-03-18, the Document has been moved to doris-website.
See Doris Document.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

@@ -128,6 +128,44 @@ BaseTablet::~BaseTablet() {
g_total_tablet_num << -1;
}

Status BaseTablet::capture_sub_txn_rs_readers(
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method 'capture_sub_txn_rs_readers' can be made const [readability-make-member-function-const]

be/src/olap/base_tablet.cpp:133:

-         std::vector<std::shared_ptr<TabletTxnInfo>>* tablet_txn_infos) {
+         std::vector<std::shared_ptr<TabletTxnInfo>>* tablet_txn_infos) const {

@@ -1344,7 +1394,10 @@
}

Status BaseTablet::update_delete_bitmap(const BaseTabletSPtr& self, TabletTxnInfo* txn_info,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'update_delete_bitmap' has cognitive complexity of 86 (threshold 50) [readability-function-cognitive-complexity]

Status BaseTablet::update_delete_bitmap(const BaseTabletSPtr& self, TabletTxnInfo* txn_info,
                   ^
Additional context

be/src/olap/base_tablet.cpp:1410: +1

            txn_info->partial_update_info && txn_info->partial_update_info->is_partial_update();
                                          ^

be/src/olap/base_tablet.cpp:1411: +1, including nesting penalty of 0, nesting level increased to 1

    if (is_partial_update) {
    ^

be/src/olap/base_tablet.cpp:1412: nesting level increased to 2

        transient_rs_writer = DORIS_TRY(self->create_transient_rowset_writer(
                              ^

be/src/common/status.h:708: expanded from macro 'DORIS_TRY'

    ({                                           \
    ^

be/src/olap/base_tablet.cpp:1412: +3, including nesting penalty of 2, nesting level increased to 3

        transient_rs_writer = DORIS_TRY(self->create_transient_rowset_writer(
                              ^

be/src/common/status.h:711: expanded from macro 'DORIS_TRY'

        if (!res.has_value()) [[unlikely]] {     \
        ^

be/src/olap/base_tablet.cpp:1424: +1, including nesting penalty of 0, nesting level increased to 1

    RETURN_IF_ERROR(std::dynamic_pointer_cast<BetaRowset>(rowset)->load_segments(&segments));
    ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1424: +2, including nesting penalty of 1, nesting level increased to 2

    RETURN_IF_ERROR(std::dynamic_pointer_cast<BetaRowset>(rowset)->load_segments(&segments));
    ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1430: +1, including nesting penalty of 0, nesting level increased to 1

        if (self->tablet_state() == TABLET_NOTREADY) {
        ^

be/src/olap/base_tablet.cpp:1435: +1, including nesting penalty of 0, nesting level increased to 1

        RETURN_IF_ERROR(self->get_all_rs_id_unlocked(next_visible_version - 1, &cur_rowset_ids));
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1435: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(self->get_all_rs_id_unlocked(next_visible_version - 1, &cur_rowset_ids));
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1450: +1, including nesting penalty of 0, nesting level increased to 1

    if (non_visible_rowsets != nullptr) {
    ^

be/src/olap/base_tablet.cpp:1455: nesting level increased to 2

                  [](RowsetSharedPtr& lhs, RowsetSharedPtr& rhs) {
                  ^

be/src/olap/base_tablet.cpp:1460: nesting level increased to 1

              [](RowsetSharedPtr& lhs, RowsetSharedPtr& rhs) {
              ^

be/src/olap/base_tablet.cpp:1470: +1, including nesting penalty of 0, nesting level increased to 1

    if (is_partial_update) {
    ^

be/src/olap/base_tablet.cpp:1483: +2, including nesting penalty of 1, nesting level increased to 2

        if (!rowsets_skip_alignment.empty()) {
        ^

be/src/olap/base_tablet.cpp:1488: +1, including nesting penalty of 0, nesting level increased to 1

    DBUG_EXECUTE_IF("BaseTablet::update_delete_bitmap.enable_spin_wait", {
    ^

be/src/util/debug_points.h:36: expanded from macro 'DBUG_EXECUTE_IF'

    if (UNLIKELY(config::enable_debug_points)) {                              \
    ^

be/src/olap/base_tablet.cpp:1488: +2, including nesting penalty of 1, nesting level increased to 2

    DBUG_EXECUTE_IF("BaseTablet::update_delete_bitmap.enable_spin_wait", {
    ^

be/src/util/debug_points.h:38: expanded from macro 'DBUG_EXECUTE_IF'

        if (dp) {                                                             \
        ^

be/src/olap/base_tablet.cpp:1490: +3, including nesting penalty of 2, nesting level increased to 3

        while (DebugPoints::instance()->is_enable("BaseTablet::update_delete_bitmap.block")) {
        ^

be/src/olap/base_tablet.cpp:1493: +4, including nesting penalty of 3, nesting level increased to 4

            if (block_dp) {
            ^

be/src/olap/base_tablet.cpp:1495: +5, including nesting penalty of 4, nesting level increased to 5

                if (wait_token != token) {
                ^

be/src/olap/base_tablet.cpp:1503: +1, including nesting penalty of 0, nesting level increased to 1

    if (!rowsets_skip_alignment.empty()) {
    ^

be/src/olap/base_tablet.cpp:1506: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(calc_delete_bitmap(self, rowset, segments, rowsets_skip_alignment,
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1506: +3, including nesting penalty of 2, nesting level increased to 3

        RETURN_IF_ERROR(calc_delete_bitmap(self, rowset, segments, rowsets_skip_alignment,
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1509: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(token->wait());
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1509: +3, including nesting penalty of 2, nesting level increased to 3

        RETURN_IF_ERROR(token->wait());
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1514: +1, including nesting penalty of 0, nesting level increased to 1

    if (segments.size() <= 1) {
    ^

be/src/olap/base_tablet.cpp:1515: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(calc_delete_bitmap(self, rowset, segments, specified_rowsets, delete_bitmap,
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1515: +3, including nesting penalty of 2, nesting level increased to 3

        RETURN_IF_ERROR(calc_delete_bitmap(self, rowset, segments, specified_rowsets, delete_bitmap,
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1519: +1, nesting level increased to 1

    } else {
      ^

be/src/olap/base_tablet.cpp:1521: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(calc_delete_bitmap(self, rowset, segments, specified_rowsets, delete_bitmap,
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1521: +3, including nesting penalty of 2, nesting level increased to 3

        RETURN_IF_ERROR(calc_delete_bitmap(self, rowset, segments, specified_rowsets, delete_bitmap,
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1524: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(token->wait());
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1524: +3, including nesting penalty of 2, nesting level increased to 3

        RETURN_IF_ERROR(token->wait());
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1532: +1, including nesting penalty of 0, nesting level increased to 1

    if (config::enable_merge_on_write_correctness_check && rowset->num_rows() != 0) {
    ^

be/src/olap/base_tablet.cpp:1532: +1

    if (config::enable_merge_on_write_correctness_check && rowset->num_rows() != 0) {
                                                        ^

be/src/olap/base_tablet.cpp:1537: +2, including nesting penalty of 1, nesting level increased to 2

        if (!st.ok()) {
        ^

be/src/olap/base_tablet.cpp:1542: +1, including nesting penalty of 0, nesting level increased to 1

    if (transient_rs_writer) {
    ^

be/src/olap/base_tablet.cpp:1544: +2, including nesting penalty of 1, nesting level increased to 2

        DBUG_EXECUTE_IF("Tablet.update_delete_bitmap.partial_update_write_rowset_fail", {
        ^

be/src/util/debug_points.h:36: expanded from macro 'DBUG_EXECUTE_IF'

    if (UNLIKELY(config::enable_debug_points)) {                              \
    ^

be/src/olap/base_tablet.cpp:1544: +3, including nesting penalty of 2, nesting level increased to 3

        DBUG_EXECUTE_IF("Tablet.update_delete_bitmap.partial_update_write_rowset_fail", {
        ^

be/src/util/debug_points.h:38: expanded from macro 'DBUG_EXECUTE_IF'

        if (dp) {                                                             \
        ^

be/src/olap/base_tablet.cpp:1545: +4, including nesting penalty of 3, nesting level increased to 4

            if (rand() % 100 < (100 * dp->param("percent", 0.5))) {
            ^

be/src/olap/base_tablet.cpp:1553: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(transient_rs_writer->flush());
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1553: +3, including nesting penalty of 2, nesting level increased to 3

        RETURN_IF_ERROR(transient_rs_writer->flush());
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1555: +2, including nesting penalty of 1, nesting level increased to 2

        RETURN_IF_ERROR(transient_rs_writer->build(transient_rowset));
        ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1555: +3, including nesting penalty of 2, nesting level increased to 3

        RETURN_IF_ERROR(transient_rs_writer->build(transient_rowset));
        ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

be/src/olap/base_tablet.cpp:1572: nesting level increased to 1

            [](size_t sum, const segment_v2::SegmentSharedPtr& s) { return sum += s->num_rows(); });
            ^

be/src/olap/base_tablet.cpp:1574: +1, including nesting penalty of 0, nesting level increased to 1

    RETURN_IF_ERROR(self->save_delete_bitmap(txn_info, txn_id, delete_bitmap,
    ^

be/src/common/status.h:629: expanded from macro 'RETURN_IF_ERROR'

    do {                                \
    ^

be/src/olap/base_tablet.cpp:1574: +2, including nesting penalty of 1, nesting level increased to 2

    RETURN_IF_ERROR(self->save_delete_bitmap(txn_info, txn_id, delete_bitmap,
    ^

be/src/common/status.h:631: expanded from macro 'RETURN_IF_ERROR'

        if (UNLIKELY(!_status_.ok())) { \
        ^

Status BaseTablet::txn_load_update_delete_bitmap(
const BaseTabletSPtr& self, TabletTxnInfo* txn_info, int64_t txn_id, int64_t txn_expiration,
const std::vector<RowsetSharedPtr>& visible_rowsets,
const std::vector<RowsetSharedPtr>& non_visible_rowsets,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'txn_load_update_delete_bitmap' exceeds recommended size/complexity thresholds [readability-function-size]

Status BaseTablet::txn_load_update_delete_bitmap(
                   ^
Additional context

be/src/olap/base_tablet.cpp:1632: 154 lines including whitespace and comments (threshold 80)

Status BaseTablet::txn_load_update_delete_bitmap(
                   ^

@@ -1410,6 +1410,108 @@ static bool try_fetch_and_parse_schema(Transaction* txn, RowsetMetaCloudPB& rows
return true;
}

void MetaServiceImpl::get_tmp_rowset(::google::protobuf::RpcController* controller,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'get_tmp_rowset' exceeds recommended size/complexity thresholds [readability-function-size]

void MetaServiceImpl::get_tmp_rowset(::google::protobuf::RpcController* controller,
                      ^
Additional context

cloud/src/meta-service/meta_service.cpp:1412: 97 lines including whitespace and comments (threshold 80)

void MetaServiceImpl::get_tmp_rowset(::google::protobuf::RpcController* controller,
                      ^

return;
}
// set tablet schema
if (rowset_meta->has_tablet_schema()) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: statement should be inside braces [readability-braces-around-statements]

Suggested change
if (rowset_meta->has_tablet_schema()) continue;
if (rowset_meta->has_tablet_schema()) { continue;
}

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

return Status::OK();
}

Status BaseTablet::txn_load_update_delete_bitmap(
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: function 'txn_load_update_delete_bitmap' exceeds recommended size/complexity thresholds [readability-function-size]

Status BaseTablet::txn_load_update_delete_bitmap(
                   ^
Additional context

be/src/olap/base_tablet.cpp:1629: 153 lines including whitespace and comments (threshold 80)

Status BaseTablet::txn_load_update_delete_bitmap(
                   ^

@mymeiyi
Copy link
Contributor Author

mymeiyi commented Oct 31, 2024

run buildall

@doris-robot
Copy link

TPC-H: Total hot run time: 41639 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 05b690b926edc209e7556c41eeb9912219aac810, data reload: false

------ Round 1 ----------------------------------
q1	17853	7768	7264	7264
q2	2088	170	165	165
q3	10632	1099	1237	1099
q4	10273	854	890	854
q5	7756	3085	3115	3085
q6	235	148	148	148
q7	1031	615	636	615
q8	9357	1982	2072	1982
q9	6641	6479	6520	6479
q10	7071	2416	2422	2416
q11	454	242	249	242
q12	416	219	221	219
q13	17789	3026	3016	3016
q14	247	213	206	206
q15	573	532	503	503
q16	624	590	576	576
q17	980	581	515	515
q18	7538	6745	6863	6745
q19	1336	1043	1004	1004
q20	471	184	181	181
q21	3983	3395	3310	3310
q22	1130	1016	1015	1015
Total cold run time: 108478 ms
Total hot run time: 41639 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7286	7235	7232	7232
q2	321	229	230	229
q3	3117	2983	3031	2983
q4	2158	1877	1801	1801
q5	5778	5789	5840	5789
q6	230	147	142	142
q7	2267	1863	1839	1839
q8	3410	3483	3452	3452
q9	9045	8988	8921	8921
q10	3620	3601	3575	3575
q11	602	493	492	492
q12	815	601	620	601
q13	10179	3155	3234	3155
q14	311	274	282	274
q15	565	528	525	525
q16	681	655	649	649
q17	1871	1659	1631	1631
q18	8328	7967	7587	7587
q19	1735	1494	1659	1494
q20	2138	1882	1883	1882
q21	5757	5624	5504	5504
q22	1158	1065	1062	1062
Total cold run time: 71372 ms
Total hot run time: 60819 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 195466 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 05b690b926edc209e7556c41eeb9912219aac810, data reload: false

query1	1207	917	892	892
query2	6217	2022	2108	2022
query3	10799	3961	4102	3961
query4	68011	29752	23562	23562
query5	5113	441	437	437
query6	397	163	164	163
query7	5678	297	307	297
query8	325	235	232	232
query9	9070	2675	2671	2671
query10	473	251	248	248
query11	17545	15359	15825	15359
query12	154	115	99	99
query13	1601	436	422	422
query14	9780	6661	7174	6661
query15	221	189	188	188
query16	7102	433	483	433
query17	1039	559	553	553
query18	1798	305	298	298
query19	199	152	152	152
query20	119	117	110	110
query21	207	100	103	100
query22	4668	4477	4429	4429
query23	34397	33687	34048	33687
query24	5962	2725	2771	2725
query25	510	407	405	405
query26	653	158	154	154
query27	1702	292	291	291
query28	4252	2473	2423	2423
query29	677	433	411	411
query30	232	153	163	153
query31	975	810	822	810
query32	70	54	58	54
query33	437	271	265	265
query34	903	521	518	518
query35	838	751	724	724
query36	1085	979	950	950
query37	118	79	75	75
query38	4347	4249	4304	4249
query39	1475	1542	1433	1433
query40	196	101	99	99
query41	49	45	50	45
query42	108	98	97	97
query43	538	496	485	485
query44	1161	815	828	815
query45	185	168	166	166
query46	1131	709	708	708
query47	1969	1854	1868	1854
query48	426	326	323	323
query49	747	423	406	406
query50	800	387	408	387
query51	7203	7176	7143	7143
query52	102	89	93	89
query53	252	181	182	181
query54	520	402	406	402
query55	78	76	75	75
query56	258	245	270	245
query57	1271	1176	1148	1148
query58	225	202	196	196
query59	3288	3063	3060	3060
query60	271	243	248	243
query61	104	102	102	102
query62	780	676	688	676
query63	210	189	186	186
query64	1374	633	605	605
query65	3305	3235	3211	3211
query66	716	306	300	300
query67	16022	15982	15687	15687
query68	3574	588	582	582
query69	427	271	254	254
query70	1201	1126	1144	1126
query71	346	252	247	247
query72	6151	4032	3974	3974
query73	759	355	363	355
query74	9908	9000	8983	8983
query75	3383	2677	2735	2677
query76	1533	1068	1054	1054
query77	471	290	271	271
query78	10391	9371	9386	9371
query79	1390	595	592	592
query80	821	431	420	420
query81	509	238	238	238
query82	985	118	116	116
query83	157	138	140	138
query84	268	67	68	67
query85	822	305	285	285
query86	344	305	281	281
query87	4857	4885	4565	4565
query88	3462	2204	2169	2169
query89	410	285	292	285
query90	1998	191	186	186
query91	144	99	100	99
query92	62	49	50	49
query93	1568	537	549	537
query94	752	291	283	283
query95	339	241	252	241
query96	609	274	289	274
query97	2897	2688	2705	2688
query98	222	209	203	203
query99	1572	1319	1306	1306
Total cold run time: 315977 ms
Total hot run time: 195466 ms

@doris-robot
Copy link

ClickBench: Total hot run time: 33.15 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 05b690b926edc209e7556c41eeb9912219aac810, data reload: false

query1	0.03	0.04	0.03
query2	0.06	0.04	0.03
query3	0.23	0.07	0.06
query4	1.63	0.10	0.10
query5	0.43	0.40	0.43
query6	1.17	0.65	0.65
query7	0.01	0.01	0.02
query8	0.04	0.03	0.03
query9	0.56	0.51	0.51
query10	0.56	0.55	0.53
query11	0.14	0.10	0.10
query12	0.14	0.11	0.11
query13	0.61	0.60	0.60
query14	2.73	2.83	2.85
query15	0.90	0.82	0.83
query16	0.38	0.39	0.36
query17	1.05	1.07	1.08
query18	0.20	0.20	0.20
query19	1.93	1.89	2.00
query20	0.01	0.01	0.01
query21	15.37	0.59	0.58
query22	2.98	2.33	1.60
query23	16.92	1.16	0.83
query24	3.47	1.97	1.51
query25	0.17	0.18	0.20
query26	0.59	0.14	0.13
query27	0.05	0.04	0.04
query28	9.19	1.10	1.07
query29	12.55	3.27	3.22
query30	0.25	0.06	0.06
query31	2.87	0.38	0.37
query32	3.27	0.46	0.46
query33	3.01	3.05	3.05
query34	17.05	4.48	4.44
query35	4.55	4.50	4.49
query36	0.66	0.49	0.49
query37	0.09	0.06	0.06
query38	0.04	0.04	0.03
query39	0.03	0.03	0.02
query40	0.16	0.12	0.12
query41	0.08	0.02	0.02
query42	0.03	0.02	0.02
query43	0.03	0.03	0.02
Total cold run time: 106.22 s
Total hot run time: 33.15 s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants