fix(rc): skip shared memory allocation in AWS Lambda#17550
Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 3 commits intomainfrom Apr 15, 2026
Merged
Conversation
4 tasks
Codeowners resolved as |
AWS Lambda does not provide /dev/shm, so the multiprocessing.Array allocation in PublisherSubscriberConnector always fails with FileNotFoundError. Since the single-subscriber refactor (74c3ab4) the connector is eagerly created at import time via the module-level remoteconfig_poller singleton, causing a noisy warning on every cold start even when remote configuration is disabled. Check in_aws_lambda() before attempting the allocation and fall back directly to _DummySharedArray without logging a warning, since this is expected behavior in Lambda — not an error condition. Resolves: DataDog/datadog-lambda-python#785
0a4cc9a to
7a02448
Compare
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: 2d83d87 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback! |
zarirhamza
added a commit
to DataDog/datadog-lambda-python
that referenced
this pull request
Apr 15, 2026
Remote configuration relies on /dev/shm for shared memory, which is unavailable in AWS Lambda. Set DD_REMOTE_CONFIGURATION_ENABLED=false before ddtrace loads (following the same pattern used for DD_TRACE_STATS_COMPUTATION_ENABLED and DD_INSTRUMENTATION_TELEMETRY_ENABLED) so the tracer knows RC is disabled from the start. This is a defense-in-depth companion to the primary fix in dd-trace-py (DataDog/dd-trace-py#17550) which skips the shared memory allocation entirely when in_aws_lambda() is detected. Integration test snapshots will need regenerating since ddtrace startup behavior changes slightly when RC is disabled from the start vs disabled later by the ASM Lambda guard. Resolves: #785
2 tasks
brettlangdon
approved these changes
Apr 15, 2026
Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com>
hamrit-dd
approved these changes
Apr 15, 2026
95f764d
into
main
593 of 595 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the
Unable to create shared memory. Features relying on remote configuration will not work as expected.warning that appears on every Lambda cold start since ddtrace v4.5.0.Closes DataDog/datadog-lambda-python#785
Root Cause
The single RC subscriber refactor (
v4.5.0) movedPublisherSubscriberConnectorcreation intoRemoteConfigClient.__init__, making it eagerly constructed when the module-levelremoteconfig_pollersingleton is instantiated at import time. Before that refactor, connectors were created lazily per-product registration and were never created in Lambda because remote config is disabled there.AWS Lambda does not provide
/dev/shm, so themultiprocessing.Arrayallocation always fails withFileNotFoundError, logging the warning even though:DD_REMOTE_CONFIGURATION_ENABLED=falseis setasm.py:284)Both guards run after the singleton is already created — too late to prevent the allocation attempt.
Changes
ddtrace/internal/remoteconfig/_connectors.py: Checkin_aws_lambda()inPublisherSubscriberConnector.__init__before attempting shared memory allocation. When in Lambda, skip directly to_DummySharedArraywithout logging a warning (this is expected behavior, not an error).tests/internal/remoteconfig/test_remoteconfig_connector.py: Add test verifying the connector uses_DummySharedArraywhenAWS_LAMBDA_FUNCTION_NAMEis set.Safety
Using
_DummySharedArrayin Lambda is safe because:.valueis the only attribute accessed on the shared array —_DummySharedArraysatisfies the full duck-typing contractconnector.read()returns[]when.valueisb"", which is handled gracefully by the subscriber dispatch chain (_dispatch_to_productscallsperiodic()on callbacks then returns early)enable()returnsFalse), so no data is ever written to the connector_DummySharedArrayalready used as theFileNotFoundErrorfallback — we just reach it earlier and without the warningCompanion PR
Defense-in-depth change in datadog-lambda-python: DataDog/datadog-lambda-python#797 (sets
DD_REMOTE_CONFIGURATION_ENABLED=falsebefore ddtrace loads)Test Plan
test_remoteconfig_connector.pytests pass (non-Lambda paths unchanged)test_connector_uses_dummy_shared_array_in_aws_lambdatest passesUnable to create shared memorywarning in Lambda cold start logs