Repository navigation
fix(remote-config): late shutdown crash #4220
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
60 changes: 60 additions & 0 deletions
60
tests/ext/live-debugger/debugger_rshutdown_remote_config.phpt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --TEST-- | ||
| Remote Config and live debugger hooks remain valid through tracer request shutdown | ||
| --SKIPIF-- | ||
| <?php include __DIR__ . '/../includes/skipif_no_dev_env.inc'; ?> | ||
| --ENV-- | ||
| DD_AGENT_HOST=request-replayer | ||
| DD_TRACE_AGENT_PORT=80 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS=0.1 | ||
| DD_TRACE_AGENT_TEST_SESSION_TOKEN=live-debugger/rshutdown_remote_config | ||
| --INI-- | ||
| datadog.trace.enabled=1 | ||
| datadog.autofinish_spans=1 | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| require __DIR__ . "/live_debugger.inc"; | ||
|
|
||
| reset_request_replayer(); | ||
| ini_set('datadog.logs_injection', '0'); | ||
|
|
||
| function instrumented(): void {} | ||
|
|
||
| final class StartSpanDuringShutdown | ||
| { | ||
| public function __destruct() | ||
| { | ||
| $span = \DDTrace\start_span(); | ||
| $span->onClose[] = function () { | ||
| // The span is closed from tracer RSHUTDOWN. Remote Config and its | ||
| // live debugger subscriber must still be active. | ||
| var_dump(count(dd_trace_internal_fn('get_loaded_remote_configs'))); | ||
| echo "onClose completed\n"; | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| put_dynamic_config_file([ | ||
| "log_injection_enabled" => true, | ||
| "dynamic_instrumentation_enabled" => true, | ||
| ]); | ||
|
|
||
| await_probe_installation(function () { | ||
| build_span_probe(["where" => ["methodName" => "instrumented"]]); | ||
| }); | ||
|
|
||
| $trigger = new StartSpanDuringShutdown(); | ||
|
|
||
| echo "request body complete\n"; | ||
|
|
||
| ?> | ||
| --CLEAN-- | ||
| <?php | ||
| require __DIR__ . "/live_debugger.inc"; | ||
| reset_request_replayer(); | ||
| ?> | ||
| --EXPECT-- | ||
| request body complete | ||
| int(2) | ||
| onClose completed |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| --TEST-- | ||
| Remote config is not reapplied after its request shutdown cleanup | ||
| --SKIPIF-- | ||
| <?php | ||
| include __DIR__ . '/../includes/skipif_no_dev_env.inc'; | ||
| ?> | ||
| --ENV-- | ||
| DD_AGENT_HOST=request-replayer | ||
| DD_TRACE_AGENT_PORT=80 | ||
| DD_TRACE_GENERATE_ROOT_SPAN=0 | ||
| DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS=0.1 | ||
| DD_TRACE_AGENT_TEST_SESSION_TOKEN=remote-config/dynamic_config_late_shutdown | ||
| --FILE-- | ||
| <?php | ||
|
|
||
| require __DIR__ . "/remote_config.inc"; | ||
| include __DIR__ . '/../includes/request_replayer.inc'; | ||
|
|
||
| final class LateRemoteConfigWrapper | ||
| { | ||
| public $context; | ||
|
|
||
| public function stream_open($path, $mode, $options, &$opened_path) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| public function stream_close() | ||
| { | ||
| // Resource destruction runs after module RSHUTDOWN. Process Remote | ||
| // Config synchronously so this lifecycle boundary is deterministic. | ||
| dd_trace_internal_fn('process_remote_config'); | ||
| echo "late close completed\n"; | ||
| } | ||
| } | ||
|
|
||
| reset_request_replayer(); | ||
| ini_set('datadog.logs_injection', '0'); | ||
|
|
||
| $path = put_dynamic_config_file([ | ||
| 'log_injection_enabled' => true, | ||
| ]); | ||
|
|
||
| \DDTrace\start_span(); | ||
| if (ini_get('datadog.logs_injection') !== '1') { | ||
| dd_trace_internal_fn('await_remote_config'); | ||
| } | ||
| var_dump(ini_get('datadog.logs_injection')); | ||
|
|
||
| stream_wrapper_register('late-remote-config', LateRemoteConfigWrapper::class); | ||
| $trigger = fopen('late-remote-config://trigger', 'r'); | ||
|
|
||
| echo "request body complete\n"; | ||
|
|
||
| ?> | ||
| --CLEAN-- | ||
| <?php | ||
| require __DIR__ . "/remote_config.inc"; | ||
| reset_request_replayer(); | ||
| ?> | ||
| --EXPECT-- | ||
| string(1) "1" | ||
| request body complete | ||
| late close completed |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.