Commit 7466374
authored
fix: Fix deadlock when snap start and using secret for api key (#853)
# Problem
When a Lambda (1) uses snap start, and (2) specifies Datadog API key
using `DD_API_KEY_SECRET_ARN`, the extension will encounter a deadlock.
For a `RwLock`, the extension first gets a read lock:
https://github.com/DataDog/datadog-lambda-extension/blob/daf633dd003447d78261e7c371838b5af21073a1/bottlecap/src/secrets/decrypt.rs#L45
then tries to get a write lock:
https://github.com/DataDog/datadog-lambda-extension/blob/daf633dd003447d78261e7c371838b5af21073a1/bottlecap/src/secrets/decrypt.rs#L65
which never finishes. This causes the function to time out.
This bug was introduced in
#717.
# This PR
Fix this bug by removing the `RwLock` usage. `AwsCredential` is only
created and used once in `resolve_secrets()`, and `resolve_secrets()` is
only called once, so there's no need to protect this struct with a lock.
# Testing
Tested on a Lambda with:
- Python 3.13 runtime
- snap start
- using `DD_API_KEY_SECRET_ARN`
Before:
- The function timed out.
- Data failed to be sent to Datadog.
After:
- The function finished without timeout.
- Data was sent to Datadog successfully.
# Notes
Jira: https://datadoghq.atlassian.net/browse/SLES-24821 parent c58a8ce commit 7466374
2 files changed
Lines changed: 27 additions & 42 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
| 239 | + | |
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | | - | |
292 | 291 | | |
293 | 292 | | |
294 | 293 | | |
295 | | - | |
| 294 | + | |
296 | 295 | | |
297 | 296 | | |
298 | 297 | | |
| |||
318 | 317 | | |
319 | 318 | | |
320 | 319 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
| 320 | + | |
326 | 321 | | |
327 | 322 | | |
328 | | - | |
329 | 323 | | |
330 | 324 | | |
331 | 325 | | |
332 | 326 | | |
333 | | - | |
334 | 327 | | |
335 | | - | |
| 328 | + | |
336 | 329 | | |
337 | 330 | | |
338 | 331 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 20 | + | |
25 | 21 | | |
26 | 22 | | |
27 | 23 | | |
| |||
42 | 38 | | |
43 | 39 | | |
44 | 40 | | |
45 | | - | |
| 41 | + | |
46 | 42 | | |
47 | | - | |
48 | | - | |
49 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
50 | 46 | | |
51 | 47 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 48 | + | |
55 | 49 | | |
56 | 50 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
67 | 59 | | |
68 | 60 | | |
69 | 61 | | |
70 | | - | |
| 62 | + | |
71 | 63 | | |
72 | 64 | | |
73 | 65 | | |
74 | | - | |
| 66 | + | |
75 | 67 | | |
76 | 68 | | |
77 | 69 | | |
| |||
82 | 74 | | |
83 | 75 | | |
84 | 76 | | |
85 | | - | |
| 77 | + | |
86 | 78 | | |
87 | 79 | | |
88 | 80 | | |
89 | 81 | | |
90 | 82 | | |
91 | 83 | | |
92 | 84 | | |
93 | | - | |
| 85 | + | |
94 | 86 | | |
95 | 87 | | |
96 | 88 | | |
| |||
0 commit comments