Skip to content

Conversation

@kaka11chen
Copy link
Contributor

@kaka11chen kaka11chen commented Apr 18, 2024

Proposed changes

Issue:

Many domestic cloud vendors are compatible with the s3 protocol. However, early versions of s3 client will only generate path style http requests (aws/aws-sdk-java-v2#763) when encountering endpoints that do not start with s3, while some cloud vendors only support virtual host style http request.

Therefore, Doris used forceVirtualHosted in S3URI to convert it into a virtual hosted path and implemented it through path style.
For example:
For s3 uri s3://my-bucket/data/file.txt, It will eventually be parsed into:

  • virtualBucket: my-bucket
  • Bucket: data (bucket must be set, otherwise the s3 client will report an error) Especially this step is particularly tricky because of the limitations of the s3 client.
  • Key: file.txt

The path style mode is used to generate an http request similar to the virtual host by setting the endpoint to virtualBucket + original endpoint, setting the bucket and key.
However, the bucket and key here are inconsistent with the original concepts of s3, but the aws client happens to be able to generate an http request similar to the virtual host through the path style mode.

However, after #30799 we have upgrade the aws sdk version from 2.17.257 to 2.20.131. The current aws s3 client can already generate a virtual host by third party by default style of http request. So in #31111 need to set the path style option, let the s3 client use doris' virtual bucket mechanism to continue working.

Finally, the virtual bucket mechanism is too confusing and tricky, and we no longer need it with the new version of s3 client.

Resolution:

Rewrite S3URI to remove tricky virtual bucket mechanism and support different uri styles by flags.

This class represents a fully qualified location in S3 for input/output operations expressed as as URI.

For AWS S3, URI common styles:

  • AWS Client Style(Hadoop S3 Style): s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88
  • Virtual Host Style: https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88
  • Path Style: https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88

Regarding the above-mentioned common styles, we can use isPathStyle to control whether to use path style
or virtual host style.
"Virtual host style" is the currently mainstream and recommended approach to use, so the default value of
isPathStyle is false.

Other Styles:

  • Virtual Host AWS Client (Hadoop S3) Mixed Style:
    s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88
  • Path AWS Client (Hadoop S3) Mixed Style:
    s3://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88

For these two styles, we can use isPathStyle and forceParsingByStandardUri
to control whether to use.
Virtual Host AWS Client (Hadoop S3) Mixed Style: isPathStyle = false && forceParsingByStandardUri = true
Path AWS Client (Hadoop S3) Mixed Style: isPathStyle = true && forceParsingByStandardUri = true

When the incoming location is url encoded, the encoded string will be returned.
For getKey(), getQueryParams() will return the encoding string

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@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.

@kaka11chen
Copy link
Contributor Author

run buildall

@kaka11chen
Copy link
Contributor Author

buildall

@kaka11chen
Copy link
Contributor Author

run buildall

@kaka11chen
Copy link
Contributor Author

run buildall

S3URI s3uri = getS3Uri(uriStr, forceVirtualHosted);
String endpoint = forceVirtualHosted
? getEndpointAndSetVirtualBucket(s3uri, otherProps) : s3uri.getBucketScheme();
String forceParsingByStandardUri = getOrDefaultAndRemove(otherProps,
Copy link
Contributor

Choose a reason for hiding this comment

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

Define the default value of forceParsingByStandardUri and usePathStyle somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

@kaka11chen
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17591	4286	4242	4242
q2	2010	193	180	180
q3	10445	1209	1230	1209
q4	10227	807	768	768
q5	7530	2660	2609	2609
q6	216	132	137	132
q7	1001	602	584	584
q8	9235	2023	2011	2011
q9	7390	6538	6528	6528
q10	8547	3535	3479	3479
q11	452	230	231	230
q12	456	225	225	225
q13	18812	2926	2928	2926
q14	269	223	224	223
q15	508	479	481	479
q16	532	382	383	382
q17	943	691	726	691
q18	7250	6704	6582	6582
q19	5880	1514	1415	1415
q20	639	314	304	304
q21	3471	2697	2757	2697
q22	356	305	311	305
Total cold run time: 113760 ms
Total hot run time: 38201 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4329	4256	4165	4165
q2	365	265	265	265
q3	2971	2740	2789	2740
q4	1859	1542	1568	1542
q5	5281	5310	5249	5249
q6	207	125	123	123
q7	2255	1852	1875	1852
q8	3186	3329	3285	3285
q9	8600	8528	8569	8528
q10	4069	3897	3947	3897
q11	623	507	515	507
q12	792	625	632	625
q13	17464	3214	3124	3124
q14	327	309	286	286
q15	521	486	484	484
q16	508	447	453	447
q17	1837	1530	1507	1507
q18	8134	8257	7854	7854
q19	1645	1518	1565	1518
q20	2029	1864	1813	1813
q21	5185	4909	5026	4909
q22	560	464	482	464
Total cold run time: 72747 ms
Total hot run time: 55184 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 185042 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 93ea50d19af19316fcf26de8569602dad43736d2, data reload: false

query1	898	360	364	360
query2	6219	2686	2371	2371
query3	6652	204	204	204
query4	24008	21190	21194	21190
query5	4127	406	413	406
query6	280	189	192	189
query7	4581	309	298	298
query8	254	191	191	191
query9	8452	2368	2348	2348
query10	411	246	252	246
query11	14721	14091	14144	14091
query12	135	94	86	86
query13	1641	385	351	351
query14	8868	8078	7498	7498
query15	288	183	184	183
query16	8248	269	258	258
query17	1984	568	585	568
query18	2112	267	268	267
query19	341	149	153	149
query20	90	87	83	83
query21	195	120	123	120
query22	5056	4921	4847	4847
query23	33869	33015	33291	33015
query24	11158	3033	3110	3033
query25	621	385	388	385
query26	1269	172	162	162
query27	2388	370	374	370
query28	7198	2082	2029	2029
query29	885	629	610	610
query30	248	178	179	178
query31	982	776	769	769
query32	90	56	52	52
query33	755	265	250	250
query34	1140	501	474	474
query35	866	698	746	698
query36	1082	904	898	898
query37	146	68	73	68
query38	3440	3362	3305	3305
query39	1614	1697	1605	1605
query40	167	128	129	128
query41	44	42	43	42
query42	103	96	95	95
query43	570	516	535	516
query44	1241	748	736	736
query45	292	284	260	260
query46	1200	764	723	723
query47	2042	1943	1957	1943
query48	387	294	299	294
query49	898	397	383	383
query50	774	396	392	392
query51	6892	6734	6772	6734
query52	94	86	89	86
query53	346	275	280	275
query54	299	238	224	224
query55	74	72	70	70
query56	236	215	220	215
query57	1203	1143	1111	1111
query58	222	206	208	206
query59	3365	3239	3290	3239
query60	263	237	248	237
query61	124	85	85	85
query62	619	445	439	439
query63	311	283	273	273
query64	5204	4053	4427	4053
query65	3103	3034	3034	3034
query66	754	322	325	322
query67	15273	14635	15003	14635
query68	5321	529	537	529
query69	532	306	303	303
query70	1207	1122	1171	1122
query71	1418	1271	1273	1271
query72	6768	2735	2580	2580
query73	704	323	321	321
query74	6784	6494	6440	6440
query75	3648	2657	2652	2652
query76	3986	970	1012	970
query77	573	346	259	259
query78	11073	10140	10173	10140
query79	8910	517	522	517
query80	2166	464	435	435
query81	539	253	239	239
query82	1613	97	99	97
query83	303	170	162	162
query84	266	82	80	80
query85	1460	265	264	264
query86	469	289	290	289
query87	3405	3274	3203	3203
query88	5503	2311	2313	2311
query89	547	372	375	372
query90	1961	180	183	180
query91	121	96	95	95
query92	55	47	44	44
query93	7222	501	494	494
query94	1033	175	241	175
query95	390	307	313	307
query96	609	260	260	260
query97	3156	2900	2925	2900
query98	235	207	209	207
query99	1243	884	869	869
Total cold run time: 296632 ms
Total hot run time: 185042 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.09	0.04	0.04
query3	0.22	0.06	0.04
query4	1.67	0.07	0.08
query5	0.50	0.50	0.50
query6	1.47	0.73	0.73
query7	0.02	0.02	0.01
query8	0.05	0.04	0.04
query9	0.56	0.50	0.51
query10	0.56	0.55	0.54
query11	0.16	0.11	0.11
query12	0.15	0.12	0.12
query13	0.62	0.58	0.58
query14	0.76	0.77	0.77
query15	0.82	0.80	0.80
query16	0.37	0.36	0.37
query17	0.94	0.93	0.96
query18	0.19	0.29	0.21
query19	1.81	1.71	1.64
query20	0.01	0.01	0.01
query21	15.40	0.67	0.66
query22	3.78	6.80	2.45
query23	18.28	1.31	1.21
query24	2.06	0.21	0.20
query25	0.12	0.09	0.08
query26	0.26	0.16	0.16
query27	0.08	0.08	0.08
query28	13.31	1.00	0.98
query29	12.57	3.26	3.25
query30	0.26	0.08	0.06
query31	2.84	0.37	0.37
query32	3.29	0.46	0.46
query33	2.74	2.86	2.83
query34	17.06	4.39	4.42
query35	4.46	4.46	4.46
query36	0.64	0.46	0.46
query37	0.19	0.15	0.15
query38	0.16	0.14	0.14
query39	0.04	0.03	0.04
query40	0.18	0.14	0.17
query41	0.10	0.05	0.05
query42	0.06	0.05	0.05
query43	0.04	0.04	0.04
Total cold run time: 108.93 s
Total hot run time: 30.73 s

@morningman
Copy link
Contributor

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17616	4310	4246	4246
q2	2015	191	186	186
q3	10452	1159	1173	1159
q4	10190	779	822	779
q5	7519	2729	2637	2637
q6	219	135	135	135
q7	1030	607	590	590
q8	9223	2058	2044	2044
q9	7366	6608	6510	6510
q10	8629	3520	3503	3503
q11	463	235	231	231
q12	434	223	210	210
q13	17760	2933	2918	2918
q14	260	222	235	222
q15	510	487	488	487
q16	520	395	371	371
q17	966	638	711	638
q18	7279	6741	6620	6620
q19	6345	1530	1530	1530
q20	639	324	309	309
q21	3464	2685	2744	2685
q22	361	320	315	315
Total cold run time: 113260 ms
Total hot run time: 38325 ms

----- Round 2, with runtime_filter_mode=off -----
q1	4389	4201	4212	4201
q2	367	269	263	263
q3	2949	2724	2745	2724
q4	1862	1557	1575	1557
q5	5328	5368	5342	5342
q6	213	125	129	125
q7	2270	1843	1861	1843
q8	3224	3435	3362	3362
q9	8598	8550	8604	8550
q10	4044	3889	3954	3889
q11	599	503	508	503
q12	830	622	631	622
q13	17424	3264	3063	3063
q14	329	300	283	283
q15	525	493	505	493
q16	506	454	445	445
q17	1829	1505	1502	1502
q18	8134	8110	7871	7871
q19	1672	1612	1591	1591
q20	2030	1831	1830	1830
q21	9643	5042	4949	4949
q22	530	468	465	465
Total cold run time: 77295 ms
Total hot run time: 55473 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 185393 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 2659aae7ba36204cb1ffb9b8a9878ad85bf9dec9, data reload: false

query1	895	382	370	370
query2	6213	2716	2468	2468
query3	6653	204	200	200
query4	23995	21397	21242	21242
query5	4199	405	411	405
query6	272	184	177	177
query7	4593	287	286	286
query8	239	189	186	186
query9	8554	2326	2320	2320
query10	417	241	254	241
query11	14783	14230	14200	14200
query12	137	95	87	87
query13	1641	366	396	366
query14	9789	8024	8020	8020
query15	263	182	180	180
query16	8251	275	249	249
query17	1971	576	561	561
query18	2099	264	263	263
query19	331	148	145	145
query20	91	84	83	83
query21	205	124	125	124
query22	5036	4790	4771	4771
query23	33630	33182	33285	33182
query24	11040	3090	3017	3017
query25	591	390	381	381
query26	736	156	155	155
query27	2436	371	354	354
query28	5602	2065	2051	2051
query29	857	634	598	598
query30	262	181	182	181
query31	1027	763	763	763
query32	92	51	53	51
query33	657	258	245	245
query34	914	477	501	477
query35	844	774	695	695
query36	1089	932	927	927
query37	114	68	69	68
query38	3537	3251	3293	3251
query39	1679	1563	1574	1563
query40	169	127	122	122
query41	48	45	42	42
query42	105	109	103	103
query43	601	568	567	567
query44	1129	753	763	753
query45	296	267	287	267
query46	1098	741	746	741
query47	2070	1975	1943	1943
query48	375	314	318	314
query49	898	408	408	408
query50	783	410	394	394
query51	6804	6741	6732	6732
query52	97	92	86	86
query53	345	274	280	274
query54	316	238	231	231
query55	74	72	70	70
query56	247	229	227	227
query57	1195	1154	1119	1119
query58	238	211	205	205
query59	3381	3302	3155	3155
query60	263	234	236	234
query61	106	105	114	105
query62	600	439	442	439
query63	305	280	282	280
query64	4848	4026	3447	3447
query65	3062	3012	3053	3012
query66	753	333	336	333
query67	15523	14912	15134	14912
query68	9225	534	549	534
query69	618	308	312	308
query70	1381	1174	1181	1174
query71	1502	1269	1270	1269
query72	6800	2796	2421	2421
query73	1608	318	315	315
query74	6751	6416	6473	6416
query75	4335	2645	2675	2645
query76	5464	937	999	937
query77	635	262	265	262
query78	11021	10231	10118	10118
query79	12065	511	521	511
query80	2695	434	427	427
query81	533	240	303	240
query82	246	91	101	91
query83	218	167	159	159
query84	263	83	81	81
query85	967	265	260	260
query86	335	308	288	288
query87	3476	3257	3295	3257
query88	5280	2361	2346	2346
query89	520	376	364	364
query90	2430	183	185	183
query91	126	96	92	92
query92	55	44	44	44
query93	7314	513	508	508
query94	1563	186	178	178
query95	422	291	308	291
query96	620	264	265	264
query97	3151	2928	2954	2928
query98	240	208	216	208
query99	1147	856	861	856
Total cold run time: 304469 ms
Total hot run time: 185393 ms

@doris-robot
Copy link

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

query1	0.04	0.03	0.03
query2	0.09	0.04	0.04
query3	0.23	0.06	0.05
query4	1.65	0.07	0.08
query5	0.50	0.50	0.48
query6	1.46	0.71	0.71
query7	0.02	0.01	0.02
query8	0.04	0.04	0.04
query9	0.55	0.50	0.49
query10	0.55	0.56	0.54
query11	0.15	0.12	0.12
query12	0.14	0.11	0.12
query13	0.60	0.58	0.58
query14	0.74	0.78	0.80
query15	0.82	0.80	0.79
query16	0.37	0.35	0.38
query17	1.02	0.95	0.93
query18	0.21	0.26	0.24
query19	1.77	1.80	1.82
query20	0.02	0.01	0.01
query21	15.41	0.66	0.64
query22	4.67	7.32	1.83
query23	18.26	1.33	1.22
query24	1.81	0.26	0.21
query25	0.15	0.08	0.09
query26	0.26	0.17	0.17
query27	0.08	0.08	0.08
query28	13.31	0.99	0.99
query29	12.60	3.29	3.28
query30	0.26	0.06	0.07
query31	2.85	0.37	0.37
query32	3.30	0.46	0.45
query33	2.86	2.86	2.81
query34	17.06	4.35	4.39
query35	4.50	4.48	4.52
query36	0.65	0.46	0.46
query37	0.18	0.16	0.14
query38	0.15	0.14	0.15
query39	0.04	0.03	0.04
query40	0.17	0.14	0.14
query41	0.09	0.04	0.04
query42	0.05	0.04	0.04
query43	0.03	0.04	0.04
Total cold run time: 109.71 s
Total hot run time: 30.22 s

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Apr 22, 2024
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

Copy link
Contributor

@wsjz wsjz left a comment

Choose a reason for hiding this comment

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

LGTM

@morningman morningman merged commit 778ab9d into apache:master Apr 22, 2024
yiguolei pushed a commit that referenced this pull request Apr 22, 2024
… bucket mechanism and support different uri styles by flags. (#33858)

Many domestic cloud vendors are compatible with the s3 protocol. However, early versions of s3 client will only generate path style http requests (aws/aws-sdk-java-v2#763) when encountering endpoints that do not start with s3, while some cloud vendors only support virtual host style http request.

Therefore, Doris used `forceVirtualHosted` in `S3URI` to convert it into a virtual hosted path and implemented it through path style.
For example:
For s3 uri `s3://my-bucket/data/file.txt`, It will eventually be parsed into:
- virtualBucket: my-bucket
- Bucket: data (bucket must be set, otherwise the s3 client will report an error) Especially this step is particularly tricky because of the limitations of the s3 client.
- Key: file.txt

 The path style mode is used to generate an http request similar to the virtual host by setting the endpoint to virtualBucket + original endpoint, setting the bucket and key.
**However, the bucket and key here are inconsistent with the original concepts of s3, but the aws client happens to be able to generate an http request similar to the virtual host through the path style mode.**

However, after #30799 we have upgrade the aws sdk version from 2.17.257 to 2.20.131. The current aws s3 client can already generate a virtual host by third party by default style of http request. So in #31111 need to set the path style option, let the s3 client use doris' virtual bucket mechanism to continue working.

**Finally, the virtual bucket mechanism is too confusing and tricky, and we no longer need it with the new version of s3 client.**

### Resolution:

Rewrite `S3URI` to remove tricky virtual bucket mechanism and support different uri styles by flags.

This class represents a fully qualified location in S3 for input/output operations expressed as as URI.
 #### For AWS S3, URI common styles:
  - AWS Client Style(Hadoop S3 Style): `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88`
  - Virtual Host Style: `https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path Style: `https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
 
  Regarding the above-mentioned common styles, we can use <code>isPathStyle</code> to control whether to use path style
  or virtual host style.
  "Virtual host style" is the currently mainstream and recommended approach to use, so the default value of
  <code>isPathStyle</code> is false.
 
  #### Other Styles:
  - Virtual Host AWS Client (Hadoop S3) Mixed Style:
    `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path AWS Client (Hadoop S3) Mixed Style:
     `s3://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
 
  For these two styles, we can use <code>isPathStyle</code> and <code>forceParsingByStandardUri</code>
  to control whether to use.
  Virtual Host AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = false && forceParsingByStandardUri = true</code>
  Path AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = true && forceParsingByStandardUri = true</code>
 
  When the incoming location is url encoded, the encoded string will be returned.
  For <code>getKey()</code>, <code>getQueryParams()</code> will return the encoding string
morningman pushed a commit to morningman/doris that referenced this pull request Apr 30, 2024
… bucket mechanism and support different uri styles by flags. (apache#33858)

Many domestic cloud vendors are compatible with the s3 protocol. However, early versions of s3 client will only generate path style http requests (aws/aws-sdk-java-v2#763) when encountering endpoints that do not start with s3, while some cloud vendors only support virtual host style http request.

Therefore, Doris used `forceVirtualHosted` in `S3URI` to convert it into a virtual hosted path and implemented it through path style.
For example:
For s3 uri `s3://my-bucket/data/file.txt`, It will eventually be parsed into:
- virtualBucket: my-bucket
- Bucket: data (bucket must be set, otherwise the s3 client will report an error) Especially this step is particularly tricky because of the limitations of the s3 client.
- Key: file.txt

 The path style mode is used to generate an http request similar to the virtual host by setting the endpoint to virtualBucket + original endpoint, setting the bucket and key.
**However, the bucket and key here are inconsistent with the original concepts of s3, but the aws client happens to be able to generate an http request similar to the virtual host through the path style mode.**

However, after apache#30799 we have upgrade the aws sdk version from 2.17.257 to 2.20.131. The current aws s3 client can already generate a virtual host by third party by default style of http request. So in apache#31111 need to set the path style option, let the s3 client use doris' virtual bucket mechanism to continue working.

**Finally, the virtual bucket mechanism is too confusing and tricky, and we no longer need it with the new version of s3 client.**

### Resolution:

Rewrite `S3URI` to remove tricky virtual bucket mechanism and support different uri styles by flags.

This class represents a fully qualified location in S3 for input/output operations expressed as as URI.
 #### For AWS S3, URI common styles:
  - AWS Client Style(Hadoop S3 Style): `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88`
  - Virtual Host Style: `https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path Style: `https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
 
  Regarding the above-mentioned common styles, we can use <code>isPathStyle</code> to control whether to use path style
  or virtual host style.
  "Virtual host style" is the currently mainstream and recommended approach to use, so the default value of
  <code>isPathStyle</code> is false.
 
  #### Other Styles:
  - Virtual Host AWS Client (Hadoop S3) Mixed Style:
    `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path AWS Client (Hadoop S3) Mixed Style:
     `s3://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
 
  For these two styles, we can use <code>isPathStyle</code> and <code>forceParsingByStandardUri</code>
  to control whether to use.
  Virtual Host AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = false && forceParsingByStandardUri = true</code>
  Path AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = true && forceParsingByStandardUri = true</code>
 
  When the incoming location is url encoded, the encoded string will be returned.
  For <code>getKey()</code>, <code>getQueryParams()</code> will return the encoding string
dataroaring pushed a commit that referenced this pull request May 1, 2024
…4.0 (#34371)

* [feature](insert)use optional location and add hive regression test (#33153)

* [feature](iceberg)The new DDL syntax is added to create iceberg partitioned tables (#33338)

support partition by :

```
create table tb1 (c1 string, ts datetime) engine = iceberg partition by (c1, day(ts)) () properties ("a"="b")
```

* [Enhancement](hive-writer) Adjust table sink exchange rebalancer params. (#33397)

Issue Number:  #31442

Change table sink exchange rebalancer params to node level and adjust these params to improve write performance by better balance.

rebalancer params:
```
DEFINE_mInt64(table_sink_partition_write_min_data_processed_rebalance_threshold,
              "26214400"); // 25MB
// Minimum partition data processed to rebalance writers in exchange when partition writing
DEFINE_mInt64(table_sink_partition_write_min_partition_data_processed_rebalance_threshold,
              "15728640"); // 15MB
```

* [feature](profile) add transaction statistics for profile (#33488)

1. commit total time
2. fs operator total time
     rename file count
     rename dir count
     delete dir count
3. add partition total time
    add partition count
4. update partition total time
    update partition count
like:
```
      -  Transaction  Commit  Time:  906ms
          -  FileSystem  Operator  Time:  833ms
              -  Rename  File  Count:  4
              -  Rename  Dir  Count:  0
              -  Delete  Dir  Count:  0
          -  HMS  Add  Partition  Time:  0ms
              -  HMS  Add  Partition  Count:  0
          -  HMS  Update  Partition  Time:  68ms
              -  HMS  Update  Partition  Count:  4
```

* [feature](iceberg) add iceberg transaction implement (#33629)

Issue #31442

add iceberg transaction

* [feature](insert)support default value when create hive table (#33666)

Issue Number: #31442

hive3 support create table with column's default value
if use hive3, we can write default value to table

* [refactor](filesystem)refactor `filesystem` interface (#33361)

1. Remame`list` to `globList` . The path of this `list` needs to have a wildcard character, and the corresponding hdfs interface is `globStatus`, so the modified name is `globList`.
2. If you only need to view files based on paths, you can use the `listFiles` operation.
3. Merge `listLocatedFiles` function into `listFiles` function.

* [opt](meta-cache) refine the meta cache (#33449)

1. Use `caffeine` instead of `guava cache` to get better performace
2. Add a new class `CacheFactory`

    All (Async)LoadingCache should be built from `CacheFactory`

3. Use separator executor for different caches

    1. rowCountRefreshExecutor
      For row count cache.
      Row count cache is an async loading cache, and we can ignore the result
      if cache missing or thread pool is full.
      So use a separate executor for this cache.

    2.  commonRefreshExecutor
      For other caches. Other caches are sync loading cache.
      But commonRefreshExecutor will be used for async refresh.
      That is, if cache entry is missing, the cache value will be loaded in caller thread, sychronously.
      if cache entry need refresh, it will be reloaded in commonRefreshExecutor.

    3. fileListingExecutor
      File listing is a heavy operation, so use a separate executor for it.
      For fileCache, the refresh operation will still use commonRefreshExecutor to trigger refresh.
      And fileListingExecutor will be used to list file.

4. Change the refresh and expire logic of caches

    For most of caches, set `refreshAfterWrite` strategy, so that
    even if the cache entry is expired, the old entry can still be
    used while new entry is being loaded.

5. Add new global variable `enable_get_row_count_from_file_list`

    Default is true, if false, will disable getting row count from file list

* [bugfix](hive)delete write path after hive insert (#33798)

Issue #31442

1. delete file according query id
2. delete write path after insert

* [Enhancement](multi-catalog) Rewrite `S3URI` to remove tricky virtual bucket mechanism and support different uri styles by flags. (#33858)

Many domestic cloud vendors are compatible with the s3 protocol. However, early versions of s3 client will only generate path style http requests (aws/aws-sdk-java-v2#763) when encountering endpoints that do not start with s3, while some cloud vendors only support virtual host style http request.

Therefore, Doris used `forceVirtualHosted` in `S3URI` to convert it into a virtual hosted path and implemented it through path style.
For example:
For s3 uri `s3://my-bucket/data/file.txt`, It will eventually be parsed into:
- virtualBucket: my-bucket
- Bucket: data (bucket must be set, otherwise the s3 client will report an error) Especially this step is particularly tricky because of the limitations of the s3 client.
- Key: file.txt

 The path style mode is used to generate an http request similar to the virtual host by setting the endpoint to virtualBucket + original endpoint, setting the bucket and key.
**However, the bucket and key here are inconsistent with the original concepts of s3, but the aws client happens to be able to generate an http request similar to the virtual host through the path style mode.**

However, after #30799 we have upgrade the aws sdk version from 2.17.257 to 2.20.131. The current aws s3 client can already generate a virtual host by third party by default style of http request. So in #31111 need to set the path style option, let the s3 client use doris' virtual bucket mechanism to continue working.

**Finally, the virtual bucket mechanism is too confusing and tricky, and we no longer need it with the new version of s3 client.**

### Resolution:

Rewrite `S3URI` to remove tricky virtual bucket mechanism and support different uri styles by flags.

This class represents a fully qualified location in S3 for input/output operations expressed as as URI.
 #### For AWS S3, URI common styles:
  - AWS Client Style(Hadoop S3 Style): `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88`
  - Virtual Host Style: `https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path Style: `https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
 
  Regarding the above-mentioned common styles, we can use <code>isPathStyle</code> to control whether to use path style
  or virtual host style.
  "Virtual host style" is the currently mainstream and recommended approach to use, so the default value of
  <code>isPathStyle</code> is false.
 
  #### Other Styles:
  - Virtual Host AWS Client (Hadoop S3) Mixed Style:
    `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path AWS Client (Hadoop S3) Mixed Style:
     `s3://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
 
  For these two styles, we can use <code>isPathStyle</code> and <code>forceParsingByStandardUri</code>
  to control whether to use.
  Virtual Host AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = false && forceParsingByStandardUri = true</code>
  Path AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = true && forceParsingByStandardUri = true</code>
 
  When the incoming location is url encoded, the encoded string will be returned.
  For <code>getKey()</code>, <code>getQueryParams()</code> will return the encoding string

* [improvement](hive)add the `queryid` to the temporary file path (#34278)

`_temp_<table_name>` to `_temp_<queryid>_<table_name>`.
Prevent users from having a table with the name `_temp_<table_name>`.

So as to partition temp dir

* [feature](Cloud) Load index data into index cache when writing data (#34046)

* [Feature](hive-writer) Implements s3 file committer. (#33937)

Issue Number: #31442

[Feature] (hive-writer) Implements s3 file committer. 

S3 committer will start multipart uploading all files on BE side, and then complete multipart upload these files on FE side. If you do not complete multi parts of a file, the file will not be visible. So in this way, the atomicity of a single file can be guaranteed. But it still cannot guarantee the atomicity of multiple files. Because hive committers have best-effort semantics, this shortens the inconsistent time window.

## ChangeList:
- Add `used_by_s3_committer` in `FileWriterOptions` on BE side to start multi-part uploading files, then complete multi-part uploading files on FE side.
- `cosn://`use s3 client on FE side, because it need to complete multi-part uploading files on FE side.
-  Add `Status directoryExists(String dir)` and `Status deleteDirectory` in `FileSystem`.

---------

Co-authored-by: slothever <18522955+wsjz@users.noreply.github.com>
Co-authored-by: wuwenchi <wuwenchihdu@hotmail.com>
Co-authored-by: Qi Chen <kaka11.chen@gmail.com>
Co-authored-by: AlexYue <yj976240184@gmail.com>
@morningman morningman mentioned this pull request May 16, 2024
1 task
w41ter pushed a commit to w41ter/incubator-doris that referenced this pull request Jul 18, 2024
… bucket mechanism and support different uri styles by flags. (apache#33858)

Many domestic cloud vendors are compatible with the s3 protocol. However, early versions of s3 client will only generate path style http requests (aws/aws-sdk-java-v2#763) when encountering endpoints that do not start with s3, while some cloud vendors only support virtual host style http request.

Therefore, Doris used `forceVirtualHosted` in `S3URI` to convert it into a virtual hosted path and implemented it through path style.
For example:
For s3 uri `s3://my-bucket/data/file.txt`, It will eventually be parsed into:
- virtualBucket: my-bucket
- Bucket: data (bucket must be set, otherwise the s3 client will report an error) Especially this step is particularly tricky because of the limitations of the s3 client.
- Key: file.txt

 The path style mode is used to generate an http request similar to the virtual host by setting the endpoint to virtualBucket + original endpoint, setting the bucket and key.
**However, the bucket and key here are inconsistent with the original concepts of s3, but the aws client happens to be able to generate an http request similar to the virtual host through the path style mode.**

However, after apache#30799 we have upgrade the aws sdk version from 2.17.257 to 2.20.131. The current aws s3 client can already generate a virtual host by third party by default style of http request. So in apache#31111 need to set the path style option, let the s3 client use doris' virtual bucket mechanism to continue working.

**Finally, the virtual bucket mechanism is too confusing and tricky, and we no longer need it with the new version of s3 client.**

Rewrite `S3URI` to remove tricky virtual bucket mechanism and support different uri styles by flags.

This class represents a fully qualified location in S3 for input/output operations expressed as as URI.
 #### For AWS S3, URI common styles:
  - AWS Client Style(Hadoop S3 Style): `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88`
  - Virtual Host Style: `https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path Style: `https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`

  Regarding the above-mentioned common styles, we can use <code>isPathStyle</code> to control whether to use path style
  or virtual host style.
  "Virtual host style" is the currently mainstream and recommended approach to use, so the default value of
  <code>isPathStyle</code> is false.

  #### Other Styles:
  - Virtual Host AWS Client (Hadoop S3) Mixed Style:
    `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`
  - Path AWS Client (Hadoop S3) Mixed Style:
     `s3://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`

  For these two styles, we can use <code>isPathStyle</code> and <code>forceParsingByStandardUri</code>
  to control whether to use.
  Virtual Host AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = false && forceParsingByStandardUri = true</code>
  Path AWS Client (Hadoop S3) Mixed Style: <code>isPathStyle = true && forceParsingByStandardUri = true</code>

  When the incoming location is url encoded, the encoded string will be returned.
  For <code>getKey()</code>, <code>getQueryParams()</code> will return the encoding string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. dev/2.1.3-merged kind/behavior-changed reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants