Commit 776ceb0
authored
Fix S3/REST infrastructure: connection lifecycle and API compliance (#12447)
* Fix S3/REST infrastructure: connection lifecycle and API compliance
(First of three PR to add backup and restore via s3/mocks3).
Fix issues in S3 and REST client infrastructure that were causing
simulation failures and API compliance problems.
PART 1: Sim2Conn Connection Lifecycle Fixes
Problem: Connection pools were destroying connections without explicitly closing
them, violating Sim2Conn's assertion (!opened || closedByCaller) in simulation.
Fixes:
1. Add destructors to connection pool classes that close all pooled connections
before destruction (RESTConnectionPool, S3BlobStoreEndpoint::ConnectionPoolData)
2. Close connections on error paths in doRequest_impl() before they go out of
scope (both REST and S3)
3. Replace static globalConnectionPool with getGlobalConnectionPool() returning
process-local pools in simulation
4. Add ReusableConnection copy control to detect cross-process copies
PART 2: S3 API Compliance and Error Handling
Problem: S3 API spec violations and incorrect error handling causing backup failures.
Fixes:
1. Strip leading slashes from S3 object keys (S3 spec: keys shouldn't start with '/')
- constructResourcePath() now removes all leading '/' characters
2. URL decode object names from S3 XML responses (S3 returns "test%20file.txt")
- listObjectsStream_impl(), BackupContainerS3BlobStore list functions
3. Fix guessRegionFromDomain() crash with localhost/127.0.0.1 (used by MockS3)
4. Only parse S3 error codes for 4xx/5xx responses, not 2xx success responses
5. Add connection validation ASSERT before handshake
6. Use flat listing in BackupContainerS3BlobStore to find all nested files
- Fixes all Sim2Conn assertion failures in S3/REST tests
- Enables S3 backups to work correctly with proper object key handling
- Fixes MockS3 testing with localhost addresses
- Simulation-only changes (g_network->isSimulated()) have no production impact
- S3 API compliance changes apply to both simulation and production
* Fix compile issue
* Formatting
* Fix rconn scope issue in S3BlobStore error handler
* Fix s3client_test to use full object path in list verification
The test was checking for 'ls_test/sub1/file2_1' but the actual S3 object
key is 's3client/ls_test/sub1/file2_1' (the full path including the path_prefix).
S3 list operations return the complete object key, not a path relative to
the prefix. This broke after the object key normalization changes that strip
leading slashes, which changed how paths were being constructed.
Fix: Extract the full path prefix from the URL and use it when verifying
the listing output, so we check for the correct full object paths.
* Formatting
* Address review improvement suggestion1 parent 886c693 commit 776ceb0
File tree
7 files changed
+223
-40
lines changed- fdbclient
- include/fdbclient
- tests
7 files changed
+223
-40
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | | - | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
89 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
93 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
94 | 100 | | |
95 | 101 | | |
96 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
148 | | - | |
149 | | - | |
| 149 | + | |
150 | 150 | | |
151 | 151 | | |
152 | 152 | | |
153 | | - | |
154 | | - | |
155 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
156 | 157 | | |
157 | 158 | | |
158 | 159 | | |
| |||
161 | 162 | | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
164 | 173 | | |
165 | 174 | | |
166 | 175 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
33 | 51 | | |
34 | 52 | | |
35 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
30 | 49 | | |
31 | 50 | | |
32 | 51 | | |
| |||
76 | 95 | | |
77 | 96 | | |
78 | 97 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | 98 | | |
83 | 99 | | |
84 | 100 | | |
| |||
199 | 215 | | |
200 | 216 | | |
201 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
202 | 223 | | |
203 | 224 | | |
204 | 225 | | |
| |||
446 | 467 | | |
447 | 468 | | |
448 | 469 | | |
449 | | - | |
450 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
451 | 476 | | |
| 477 | + | |
452 | 478 | | |
453 | | - | |
454 | 479 | | |
455 | 480 | | |
456 | 481 | | |
| |||
843 | 868 | | |
844 | 869 | | |
845 | 870 | | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
846 | 875 | | |
847 | 876 | | |
848 | 877 | | |
| |||
1074 | 1103 | | |
1075 | 1104 | | |
1076 | 1105 | | |
| 1106 | + | |
1077 | 1107 | | |
1078 | 1108 | | |
1079 | 1109 | | |
| |||
1095 | 1125 | | |
1096 | 1126 | | |
1097 | 1127 | | |
1098 | | - | |
1099 | | - | |
| 1128 | + | |
1100 | 1129 | | |
1101 | 1130 | | |
1102 | 1131 | | |
| |||
1140 | 1169 | | |
1141 | 1170 | | |
1142 | 1171 | | |
1143 | | - | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
1144 | 1177 | | |
1145 | 1178 | | |
1146 | 1179 | | |
| |||
1206 | 1239 | | |
1207 | 1240 | | |
1208 | 1241 | | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
1209 | 1250 | | |
1210 | 1251 | | |
1211 | | - | |
1212 | 1252 | | |
1213 | 1253 | | |
1214 | 1254 | | |
| |||
1263 | 1303 | | |
1264 | 1304 | | |
1265 | 1305 | | |
1266 | | - | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1267 | 1312 | | |
1268 | 1313 | | |
1269 | 1314 | | |
| |||
1466 | 1511 | | |
1467 | 1512 | | |
1468 | 1513 | | |
1469 | | - | |
| 1514 | + | |
| 1515 | + | |
1470 | 1516 | | |
1471 | 1517 | | |
1472 | 1518 | | |
| |||
2038 | 2084 | | |
2039 | 2085 | | |
2040 | 2086 | | |
2041 | | - | |
2042 | | - | |
2043 | | - | |
2044 | | - | |
2045 | | - | |
2046 | | - | |
2047 | | - | |
2048 | | - | |
2049 | | - | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
2050 | 2093 | | |
2051 | 2094 | | |
2052 | 2095 | | |
| |||
2490 | 2533 | | |
2491 | 2534 | | |
2492 | 2535 | | |
2493 | | - | |
| 2536 | + | |
| 2537 | + | |
| 2538 | + | |
| 2539 | + | |
| 2540 | + | |
| 2541 | + | |
| 2542 | + | |
| 2543 | + | |
| 2544 | + | |
| 2545 | + | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| |||
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
61 | 68 | | |
62 | 69 | | |
63 | 70 | | |
| |||
0 commit comments