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

[bug](s3) fix S3 file system gets absolute path #44965

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

DarvenDuan
Copy link
Contributor

@DarvenDuan DarvenDuan commented Dec 4, 2024

What problem does this PR solve?

Issue Number: close #44902

Related PR: #xxx

Problem Summary

If we create a S3 resource for cooldown data storage and the s3.root.path has a leading slash(/), such as: /root, the remote S3 data file will not be deleted if we drop the cooldown tablet from Doris.

Reason

Doris will get the path of all files of a tablet and then delete those files, The AWS S3Client:ListObjectsV2 uses objects prefix to get the object files, but if the prefix has a leading slash(/), theS3Client:ListObjectsV2 gets empty result.

Solution

use _prefix instead of _root_path in S3FileSystem for getting absolute path, _prefix is normalized in constructor and it is removed the first and last '/'.

test case

  1. create a s3 resource with a leading '/' and a storage policy base on it:
CREATE RESOURCE "test_resource"
PROPERTIES
(
    "type" = "s3",
    "s3.endpoint" = "xxx",
    "s3.region" = "xxx",
    "s3.bucket" = "xxx",
    "s3.root.path" = "/tmp",
    "s3.access_key" = "xx",
    "s3.secret_key" = "xx"
);

CREATE STORAGE POLICY test_policy PROPERTIES (
    "storage_resource" = "test_resource",
    "cooldown_ttl" = "1"
)
  1. create a table and set the storage_policy to test_policy and insert test data:
CREATE TABLE `test_table` (
  `k` bigint,
  `v` bigint
) ENGINE=OLAP
DUPLICATE KEY(`k`)
DISTRIBUTED BY HASH(`k`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"storage_policy" = "test_policy"
);

insert into test_table values (1,2),(2,3);
  1. wait for the rowset cooldown to s3.
  2. truncate test table
truncate table test_table force;
  1. If we get a log like delete remote rowsets of tablet. root_path="/tmp", tablet_id=xxx in be.INFO, the remote tablet file should be deleted.

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:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • 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

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

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?

@@ -121,7 +121,7 @@ class S3FileSystem final : public RemoteFileSystem {
abs_path = path;
} else {
// path with no schema
abs_path = _root_path / path;
abs_path = _prefix / path;
Copy link
Contributor Author

@DarvenDuan DarvenDuan Dec 4, 2024

Choose a reason for hiding this comment

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

_prefix is normalized in constructor, it is removed the first and last '/'

@DarvenDuan
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
q1	17568	7568	7338	7338
q2	2043	173	177	173
q3	10604	1128	1184	1128
q4	10554	769	744	744
q5	7635	2771	2721	2721
q6	240	155	148	148
q7	993	615	594	594
q8	9250	1883	1961	1883
q9	6785	6524	6503	6503
q10	7035	2328	2334	2328
q11	461	263	258	258
q12	417	227	219	219
q13	17775	3032	3015	3015
q14	253	206	211	206
q15	572	540	512	512
q16	673	582	585	582
q17	1004	531	624	531
q18	7406	6669	6789	6669
q19	1324	1014	1063	1014
q20	455	184	178	178
q21	4007	3255	3258	3255
q22	371	316	324	316
Total cold run time: 107425 ms
Total hot run time: 40315 ms

----- Round 2, with runtime_filter_mode=off -----
q1	7274	7277	7295	7277
q2	333	246	229	229
q3	2925	2902	2884	2884
q4	2175	1817	1896	1817
q5	5668	5716	5694	5694
q6	221	144	138	138
q7	2265	1808	1802	1802
q8	3461	3573	3539	3539
q9	9065	9099	8959	8959
q10	3603	3578	3538	3538
q11	594	512	497	497
q12	799	596	632	596
q13	11193	3233	3199	3199
q14	314	290	288	288
q15	581	527	521	521
q16	676	650	652	650
q17	1885	1650	1643	1643
q18	8318	7898	7543	7543
q19	1741	1663	1621	1621
q20	2116	1839	1867	1839
q21	5620	5449	5503	5449
q22	659	615	574	574
Total cold run time: 71486 ms
Total hot run time: 60297 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 198303 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 c45f3651e277e56bc2b2795e334a9c3f0169cf83, data reload: false

query1	1241	988	930	930
query2	6225	2035	1981	1981
query3	10972	4379	4382	4379
query4	67237	28870	23948	23948
query5	4960	476	460	460
query6	402	186	187	186
query7	5523	315	299	299
query8	320	240	240	240
query9	8495	2704	2700	2700
query10	440	252	254	252
query11	17093	15296	16146	15296
query12	156	102	107	102
query13	1439	446	440	440
query14	10868	7495	7269	7269
query15	205	193	195	193
query16	7069	476	473	473
query17	1053	585	581	581
query18	1728	301	300	300
query19	200	143	185	143
query20	119	111	112	111
query21	209	111	106	106
query22	4727	4613	4718	4613
query23	35104	34525	34546	34525
query24	5475	2536	2527	2527
query25	486	383	393	383
query26	643	163	158	158
query27	2027	295	294	294
query28	4603	2497	2457	2457
query29	675	423	418	418
query30	220	151	150	150
query31	1006	840	845	840
query32	69	60	67	60
query33	413	284	289	284
query34	957	530	510	510
query35	876	758	748	748
query36	1078	943	959	943
query37	129	78	105	78
query38	4409	4476	4491	4476
query39	1537	1483	1487	1483
query40	203	104	101	101
query41	52	44	47	44
query42	111	100	96	96
query43	543	496	478	478
query44	1213	846	836	836
query45	182	169	169	169
query46	1191	718	720	718
query47	2090	1957	1944	1944
query48	416	327	325	325
query49	709	405	399	399
query50	929	405	384	384
query51	7350	7211	7087	7087
query52	101	93	87	87
query53	253	173	176	173
query54	522	403	390	390
query55	75	73	80	73
query56	251	224	223	223
query57	1278	1117	1142	1117
query58	215	209	226	209
query59	3131	3083	3019	3019
query60	283	242	240	240
query61	104	109	107	107
query62	834	680	664	664
query63	217	183	197	183
query64	1371	675	686	675
query65	3324	3204	3191	3191
query66	701	300	306	300
query67	15900	15724	15916	15724
query68	4267	589	555	555
query69	424	256	263	256
query70	1123	1130	1047	1047
query71	356	244	253	244
query72	6415	4201	4057	4057
query73	799	364	362	362
query74	10352	9053	8958	8958
query75	3401	2664	2670	2664
query76	1829	1070	1139	1070
query77	502	268	264	264
query78	10374	9413	9482	9413
query79	1980	616	646	616
query80	1394	426	423	423
query81	517	236	231	231
query82	1280	116	123	116
query83	258	151	137	137
query84	278	70	70	70
query85	1033	312	312	312
query86	407	303	302	302
query87	4691	4694	4581	4581
query88	3509	2261	2172	2172
query89	415	300	284	284
query90	1969	189	191	189
query91	134	104	106	104
query92	60	47	51	47
query93	2748	550	548	548
query94	837	287	288	287
query95	348	251	249	249
query96	644	278	278	278
query97	2824	2654	2696	2654
query98	217	196	195	195
query99	1611	1335	1326	1326
Total cold run time: 320933 ms
Total hot run time: 198303 ms

@doris-robot
Copy link

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

query1	0.03	0.04	0.03
query2	0.06	0.04	0.03
query3	0.23	0.08	0.06
query4	1.62	0.10	0.11
query5	0.42	0.40	0.43
query6	1.15	0.66	0.66
query7	0.02	0.02	0.01
query8	0.04	0.03	0.03
query9	0.57	0.51	0.49
query10	0.55	0.56	0.56
query11	0.14	0.10	0.11
query12	0.15	0.11	0.11
query13	0.62	0.62	0.61
query14	2.70	2.74	2.77
query15	0.89	0.82	0.82
query16	0.39	0.39	0.38
query17	1.01	1.06	1.06
query18	0.23	0.22	0.22
query19	1.95	1.80	1.98
query20	0.02	0.01	0.01
query21	15.35	0.61	0.59
query22	2.47	2.32	1.92
query23	17.05	1.01	0.83
query24	3.37	1.26	2.41
query25	0.12	0.23	0.06
query26	0.72	0.13	0.14
query27	0.06	0.04	0.05
query28	9.29	1.10	1.08
query29	12.54	3.23	3.27
query30	0.25	0.06	0.06
query31	2.85	0.38	0.38
query32	3.28	0.47	0.46
query33	3.02	3.08	3.06
query34	16.85	4.50	4.48
query35	4.54	4.45	4.44
query36	0.66	0.48	0.50
query37	0.09	0.06	0.06
query38	0.04	0.03	0.03
query39	0.04	0.02	0.03
query40	0.16	0.13	0.13
query41	0.08	0.02	0.02
query42	0.03	0.03	0.02
query43	0.04	0.03	0.03
Total cold run time: 105.69 s
Total hot run time: 33.03 s

@doris-robot
Copy link

TeamCity be ut coverage result:
Function Coverage: 38.51% (10009/25990)
Line Coverage: 29.50% (83796/284075)
Region Coverage: 28.63% (43109/150580)
Branch Coverage: 25.23% (21910/86834)
Coverage Report: http://coverage.selectdb-in.cc/coverage/c45f3651e277e56bc2b2795e334a9c3f0169cf83_c45f3651e277e56bc2b2795e334a9c3f0169cf83/report/index.html

@DarvenDuan
Copy link
Contributor Author

run cloud_p0

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

github-actions bot commented Dec 9, 2024

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

Copy link
Contributor

github-actions bot commented Dec 9, 2024

PR approved by anyone and no changes requested.

Copy link
Contributor

@GoGoWen GoGoWen left a comment

Choose a reason for hiding this comment

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

LGMT

@GoGoWen GoGoWen merged commit 0ec35de into apache:master Dec 9, 2024
33 of 36 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 9, 2024
### What problem does this PR solve?

Issue Number: close #44902

Related PR: #xxx

###  Problem Summary
If we create a S3 resource for cooldown data storage and the
s3.root.path has a leading slash(/), such as: /root, the remote S3 data
file will not be deleted if we drop the cooldown tablet from Doris.

### Reason
Doris will get the path of all files of a tablet and then delete those
files, The AWS `S3Client:ListObjectsV2` uses objects prefix to get the
object files, but if the prefix has a leading slash(/),
the`S3Client:ListObjectsV2` gets empty result.

### Solution
use _prefix instead of _root_path in S3FileSystem for getting absolute
path, _prefix is normalized in constructor and it is removed the first
and last '/'.

### test case
1. create a s3 resource with a leading '/' and a storage policy base on
it:
```
CREATE RESOURCE "test_resource"
PROPERTIES
(
    "type" = "s3",
    "s3.endpoint" = "xxx",
    "s3.region" = "xxx",
    "s3.bucket" = "xxx",
    "s3.root.path" = "/tmp",
    "s3.access_key" = "xx",
    "s3.secret_key" = "xx"
);

CREATE STORAGE POLICY test_policy PROPERTIES (
    "storage_resource" = "test_resource",
    "cooldown_ttl" = "1"
)
```
2. create a table and set the storage_policy to `test_policy` and insert
test data:
```
CREATE TABLE `test_table` (
  `k` bigint,
  `v` bigint
) ENGINE=OLAP
DUPLICATE KEY(`k`)
DISTRIBUTED BY HASH(`k`) BUCKETS 1
PROPERTIES (
"replication_num" = "1",
"storage_policy" = "test_policy"
);

insert into test_table values (1,2),(2,3);
```
3. wait for the rowset cooldown to s3.
4. truncate test table
```
truncate table test_table force;
```
5. If we get a log like ` delete remote rowsets of tablet.
root_path="/tmp", tablet_id=xxx` in be.INFO, the remote tablet file
should be deleted.

### Release note

None

### Check List (For Author)

- Test <!-- At least one of them must be included. -->
    - [x] Regression test
    - [x] Unit Test
    - [x] Manual test (add detailed scripts or steps below)
    - [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
        - [ ] Previous test can cover this change.
        - [ ] No code files have been changed.
        - [ ] Other reason <!-- Add your reason?  -->

- Behavior changed:
    - [x] No.
    - [ ] Yes. <!-- Explain the behavior change -->

- Does this need documentation?
    - [x] No.
- [ ] Yes. <!-- Add document PR link here. eg:
apache/doris-website#1214 -->

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

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
dataroaring pushed a commit that referenced this pull request Dec 9, 2024
…45199)

Cherry-picked from #44965

Co-authored-by: Xujian Duan <50550370+DarvenDuan@users.noreply.github.com>
yiguolei pushed a commit that referenced this pull request Dec 18, 2024
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.8-merged dev/3.0.4-merged reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Can't list S3 objects if the root path of S3 resource has a leading slash
6 participants