Skip to content

[fix](be) Restore SNII proto field numbers to the shipped layout - #67135

Open
airborne12 wants to merge 1 commit into
apache:masterfrom
airborne12:fix-snii-proto-field-numbers
Open

[fix](be) Restore SNII proto field numbers to the shipped layout#67135
airborne12 wants to merge 1 commit into
apache:masterfrom
airborne12:fix-snii-proto-field-numbers

Conversation

@airborne12

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: None

Related PR: #66052

Problem Summary: SNII shipped before its metadata messages reached upstream, and
the version upstreamed in #66052 had INSERTED fields in the middle of two of
them rather than appending. protobuf identifies a field by its tag, so the two
layouts now disagree about what a tag means, and every SNII segment already
written decodes incorrectly under the upstream numbering:

SniiStatsPB shipped upstream (#66052)
tag 4 null_count sum_total_term_freq
tag 5 -- null_count

SniiSectionRefsPB shipped upstream (#66052)
tag 3 null_bitmap norms
tag 4 bsbf null_bitmap
tag 5 -- bsbf

Neither misread fails. SniiStatsPB tags 4 and 5 are both uint64, so a null count
is returned as the collection token sum and feeds avgdl -- a plausible wrong
number with no error anywhere. In SniiSectionRefsPB the null bitmap's
offset/length is taken for the norms region and bsbf is lost entirely.

This PR renumbers both messages back to the shipped layout and appends the two
upstream additions after it: sum_total_term_freq becomes 5 and norms becomes 5
in their respective messages. SniiCommonGramsMetadataPB needed no change -- its
upstream fields 8-12 were appended, which is the shape every future addition
must follow.

A new case set asserts the field numbers through protobuf reflection rather than
through a byte digest, so the next accidental insert fails with a message naming
the field and both tags instead of an opaque checksum mismatch.

The twelve SniiWriterGoldenBytes digests were RE-HARVESTED: field tags and the
field-number ordering are part of the serialized Core metadata that every SNII
segment carries, so all of them moved -- including kGoldenKeywordDocsOnly, whose
index has neither norms nor a null bitmap. That one moving is the evidence the
change reaches every segment shape rather than one lane.

COMPATIBILITY: this changes how existing bytes decode, deliberately. Segments
written by an upstream build carrying #66052 are not readable afterwards and
must be rebuilt; the format is not yet released upstream, so that population is
development data only. Segments written by the shipped build become readable,
which is the point.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • SniiProtoFieldNumbers.* (4 cases, one per metadata message)
      • SniiWriterGoldenBytes.* re-harvested and green
      • Full inverted-index suites: 3210 tests, 0 failures
      • ./run-be-ut.sh -j 160 --run
  • Behavior changed:

  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66052

Problem Summary: SNII shipped before its metadata messages reached upstream, and
the version upstreamed in apache#66052 had INSERTED fields in the middle of two of
them rather than appending. protobuf identifies a field by its tag, so the two
layouts now disagree about what a tag means, and every SNII segment already
written decodes incorrectly under the upstream numbering:

  SniiStatsPB           shipped        upstream (apache#66052)
    tag 4               null_count     sum_total_term_freq
    tag 5               --             null_count

  SniiSectionRefsPB     shipped        upstream (apache#66052)
    tag 3               null_bitmap    norms
    tag 4               bsbf           null_bitmap
    tag 5               --             bsbf

Neither misread fails. SniiStatsPB tags 4 and 5 are both uint64, so a null count
is returned as the collection token sum and feeds avgdl -- a plausible wrong
number with no error anywhere. In SniiSectionRefsPB the null bitmap's
offset/length is taken for the norms region and bsbf is lost entirely.

This PR renumbers both messages back to the shipped layout and appends the two
upstream additions after it: sum_total_term_freq becomes 5 and norms becomes 5
in their respective messages. SniiCommonGramsMetadataPB needed no change -- its
upstream fields 8-12 were appended, which is the shape every future addition
must follow.

A new case set asserts the field numbers through protobuf reflection rather than
through a byte digest, so the next accidental insert fails with a message naming
the field and both tags instead of an opaque checksum mismatch.

The twelve SniiWriterGoldenBytes digests were RE-HARVESTED: field tags and the
field-number ordering are part of the serialized Core metadata that every SNII
segment carries, so all of them moved -- including kGoldenKeywordDocsOnly, whose
index has neither norms nor a null bitmap. That one moving is the evidence the
change reaches every segment shape rather than one lane.

COMPATIBILITY: this changes how existing bytes decode, deliberately. Segments
written by an upstream build carrying apache#66052 are not readable afterwards and
must be rebuilt; the format is not yet released upstream, so that population is
development data only. Segments written by the shipped build become readable,
which is the point.

### Release note

None

### Check List (For Author)

- Test
    - [ ] Regression test
    - [x] Unit Test
    - [ ] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:
        - SniiProtoFieldNumbers.* (4 cases, one per metadata message)
        - SniiWriterGoldenBytes.* re-harvested and green
        - Full inverted-index suites: 3210 tests, 0 failures
        - ./run-be-ut.sh -j 160 --run

- Behavior changed:
    - [ ] No.
    - [x] Yes. SNII segments written by an upstream build carrying apache#66052 must be
      rebuilt.

- Does this need documentation?
    - [x] No.
    - [ ] Yes.

### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
@hello-stephen

Copy link
Copy Markdown
Contributor

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

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@airborne12

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17246	3118	3072	3072
q2	2099	259	234	234
q3	10046	930	521	521
q4	4660	245	201	201
q5	7732	552	392	392
q6	138	112	93	93
q7	532	492	374	374
q8	9292	898	932	898
q9	3483	2400	2385	2385
q10	6503	868	714	714
q11	401	195	178	178
q12	613	264	191	191
q13	18147	1523	1159	1159
q14	166	149	136	136
q15	q16	445	393	364	364
q17	1385	888	814	814
q18	3069	2240	2232	2232
q19	2566	943	818	818
q20	380	282	194	194
q21	5571	1644	1858	1644
q22	322	269	223	223
Total cold run time: 94796 ms
Total hot run time: 16837 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3501	3364	3359	3359
q2	519	412	370	370
q3	2203	2406	2174	2174
q4	1187	1164	902	902
q5	2207	2129	2083	2083
q6	181	117	85	85
q7	1014	958	867	867
q8	1600	1419	1407	1407
q9	3135	3117	3100	3100
q10	1883	1796	1617	1617
q11	359	264	261	261
q12	462	429	349	349
q13	1480	1547	1178	1178
q14	172	179	170	170
q15	q16	398	396	367	367
q17	3584	3353	3269	3269
q18	4784	4405	4704	4405
q19	1032	885	866	866
q20	960	998	846	846
q21	3725	3045	3200	3045
q22	398	343	332	332
Total cold run time: 34784 ms
Total hot run time: 31052 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81971 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 afcd0ae26643e396d744ea07fe71a3925d535e5c, data reload: false

query5	4265	405	330	330
query6	380	134	126	126
query7	4964	423	227	227
query8	296	119	115	115
query9	8671	2871	2877	2871
query10	379	225	182	182
query11	5393	1028	902	902
query12	125	70	71	70
query13	1187	453	315	315
query14	6066	2172	2067	2067
query14_1	1952	1949	2031	1949
query15	173	113	106	106
query16	912	369	330	330
query17	783	454	371	371
query18	2324	328	234	234
query19	165	143	115	115
query20	71	71	69	69
query21	204	102	88	88
query22	5459	5305	5480	5305
query23	6672	6190	5914	5914
query23_1	5923	6176	6137	6137
query24	7235	1080	786	786
query24_1	772	770	765	765
query25	437	308	267	267
query26	1240	230	132	132
query27	2802	415	256	256
query28	4625	1491	1495	1491
query29	938	450	364	364
query30	259	156	130	130
query31	820	393	348	348
query32	128	71	71	71
query33	461	211	180	180
query34	987	834	490	490
query35	402	399	330	330
query36	569	569	545	545
query37	118	85	105	85
query38	1014	857	811	811
query39	478	508	480	480
query39_1	461	459	469	459
query40	197	91	73	73
query41	56	54	50	50
query42	73	69	70	69
query43	238	238	210	210
query44	1003	554	541	541
query45	111	104	98	98
query46	769	833	534	534
query47	774	770	706	706
query48	305	303	221	221
query49	547	231	184	184
query50	710	262	197	197
query51	8211	8134	8219	8134
query52	66	70	60	60
query53	194	197	148	148
query54	219	164	160	160
query55	72	58	53	53
query56	286	168	148	148
query57	705	652	660	652
query58	206	155	157	155
query59	1235	1215	1116	1116
query60	231	186	168	168
query61	112	115	118	115
query62	350	205	175	175
query63	172	140	139	139
query64	2734	682	609	609
query65	1562	1583	1586	1583
query66	1840	258	201	201
query67	10014	9476	9732	9476
query68	2758	1268	752	752
query69	342	226	205	205
query70	652	635	620	620
query71	247	187	170	170
query72	2420	1854	1577	1577
query73	656	568	350	350
query74	1563	1226	1119	1119
query75	1164	1075	968	968
query76	2224	721	567	567
query77	249	267	220	220
query78	3845	3676	3233	3233
query79	2941	825	603	603
query80	1634	320	295	295
query81	500	158	135	135
query82	616	124	93	93
query83	283	203	185	185
query84	290	112	91	91
query85	834	373	290	290
query86	412	180	159	159
query87	1023	977	877	877
query88	2873	2108	2096	2096
query89	287	197	174	174
query90	1931	133	130	130
query91	130	121	100	100
query92	79	66	67	66
query93	1839	1063	723	723
query94	623	247	229	229
query95	519	267	229	229
query96	778	603	264	264
query97	1069	1034	988	988
query98	166	135	129	129
query99	421	346	309	309
Total cold run time: 177895 ms
Total hot run time: 81971 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 16.32 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit afcd0ae26643e396d744ea07fe71a3925d535e5c, data reload: false

query1	0.01	0.00	0.00
query2	0.12	0.06	0.07
query3	0.32	0.20	0.21
query4	1.60	0.20	0.20
query5	0.26	0.24	0.24
query6	1.15	0.39	0.39
query7	0.03	0.00	0.00
query8	0.07	0.06	0.05
query9	0.40	0.27	0.28
query10	0.38	0.39	0.39
query11	0.27	0.15	0.16
query12	0.27	0.15	0.15
query13	0.38	0.37	0.37
query14	0.46	0.44	0.45
query15	0.49	0.40	0.39
query16	0.28	0.29	0.28
query17	0.64	0.67	0.66
query18	0.25	0.24	0.22
query19	1.15	1.11	1.14
query20	0.01	0.01	0.01
query21	15.40	0.28	0.24
query22	4.86	0.11	0.10
query23	15.92	0.38	0.24
query24	2.62	0.49	0.33
query25	0.13	0.07	0.08
query26	0.70	0.21	0.17
query27	0.08	0.08	0.07
query28	3.46	0.60	0.34
query29	12.44	3.30	2.66
query30	0.33	0.22	0.22
query31	2.76	0.39	0.21
query32	3.46	0.35	0.26
query33	1.34	1.48	1.40
query34	15.37	2.27	1.87
query35	1.83	1.80	1.80
query36	0.51	0.36	0.35
query37	0.09	0.06	0.07
query38	0.07	0.05	0.05
query39	0.06	0.05	0.05
query40	0.13	0.10	0.10
query41	0.12	0.06	0.06
query42	0.06	0.05	0.04
query43	0.06	0.05	0.05
Total cold run time: 90.34 s
Total hot run time: 16.32 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 62.51% (29187/46688)
Line Coverage 47.54% (305479/642530)
Region Coverage 43.21% (246715/570969)
Branch Coverage 44.78% (114873/256529)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 75.93% (34336/45221)
Line Coverage 60.92% (386955/635185)
Region Coverage 57.01% (324259/568805)
Branch Coverage 57.92% (148152/255804)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 100% (0/0) 🎉
Increment coverage report
Complete coverage report

@airborne12

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.99% (2045/2622)
Line Coverage 65.68% (37370/56895)
Region Coverage 52.97% (34876/65845)
Branch Coverage 56.37% (11194/19858)

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