Skip to content

[fleet installer] Try to fix Gac Installer issue when older versions are already installed #6715

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 4 commits into from
Mar 12, 2025

Conversation

andrewlock
Copy link
Member

@andrewlock andrewlock commented Feb 25, 2025

Summary of changes

Fixes the issue of removing old GAC entries when there are multiple assemblies in the GAC with the same name.

Reason for change

#6714 highlighted an issue with the GAC uninstall where we were not removing the previous Datadog.Trace entries during uninstall. This attempts to work around that.

Implementation details

Use another Fusion API to enumerate all the "Datadog.Trace" assemblies, to get their fullnames (e.g. Datadog.Trace, Version=3.12.0.0, Culture=neutral, PublicKeyToken=def86d061d0d2eeb, processorArchitecture=MSIL).

We then run the uninstall for all of the GAC assemblies we find. As long as each assembly has been registered with a different associated filepath (i.e. the associated native loader for the gac'd file), then we should only ever remove a single file at most. The integration tests demonstrate this works, even if it's a bit messy.

Test coverage

Unskipped the previously skipped GAC tests, and they pass so 🤞

Other details

Initially I wanted to use CreateInstallReferenceEnum() to enumerate the actual references so that we could be sure we only try to remove the correct reference, but I couldn't get that to work (Getting an HResult error 🤷‍♂️). The current approach appears to work though, so maybe we should just consider that an optimisation for later? 🤷‍♂️ I also haven't looked to see if we have any existing implementation of the API...

Stacked on

@andrewlock andrewlock requested a review from a team as a code owner February 25, 2025 16:19
@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Feb 25, 2025

Datadog Report

Branch report: andrew/win-ssi/update-gac-uninstaller
Commit report: 4d48037
Test service: dd-trace-dotnet

✅ 0 Failed, 250150 Passed, 2408 Skipped, 19h 43m 7.92s Total Time

@andrewlock
Copy link
Member Author

andrewlock commented Feb 25, 2025

Execution-Time Benchmarks Report ⏱️

Execution-time results for samples comparing the following branches/commits:

Execution-time benchmarks measure the whole time it takes to execute a program. And are intended to measure the one-off costs. Cases where the execution time results for the PR are worse than latest master results are shown in red. The following thresholds were used for comparing the execution times:

  • Welch test with statistical test for significance of 5%
  • Only results indicating a difference greater than 5% and 5 ms are considered.

Note that these results are based on a single point-in-time result for each branch. For full results, see the dashboard.

Graphs show the p99 interval based on the mean and StdDev of the test run, as well as the mean value of the run (shown as a diamond below the graph).

gantt
    title Execution time (ms) FakeDbCommand (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6715) - mean (69ms)  : 66, 72
     .   : milestone, 69,
    master - mean (68ms)  : 66, 71
     .   : milestone, 68,

    section CallTarget+Inlining+NGEN
    This PR (6715) - mean (1,006ms)  : 981, 1031
     .   : milestone, 1006,
    master - mean (1,003ms)  : 982, 1024
     .   : milestone, 1003,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6715) - mean (102ms)  : 100, 104
     .   : milestone, 102,
    master - mean (102ms)  : 99, 104
     .   : milestone, 102,

    section CallTarget+Inlining+NGEN
    This PR (6715) - mean (689ms)  : 670, 708
     .   : milestone, 689,
    master - mean (685ms)  : 666, 703
     .   : milestone, 685,

Loading
gantt
    title Execution time (ms) FakeDbCommand (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6715) - mean (89ms)  : 87, 92
     .   : milestone, 89,
    master - mean (89ms)  : 87, 90
     .   : milestone, 89,

    section CallTarget+Inlining+NGEN
    This PR (6715) - mean (639ms)  : 625, 653
     .   : milestone, 639,
    master - mean (639ms)  : 625, 654
     .   : milestone, 639,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Framework 4.6.2) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6715) - mean (190ms)  : 185, 195
     .   : milestone, 190,
    master - mean (189ms)  : 185, 192
     .   : milestone, 189,

    section CallTarget+Inlining+NGEN
    This PR (6715) - mean (1,104ms)  : 1080, 1128
     .   : milestone, 1104,
    master - mean (1,104ms)  : 1080, 1128
     .   : milestone, 1104,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET Core 3.1) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6715) - mean (269ms)  : 265, 273
     .   : milestone, 269,
    master - mean (268ms)  : 264, 271
     .   : milestone, 268,

    section CallTarget+Inlining+NGEN
    This PR (6715) - mean (872ms)  : 834, 909
     .   : milestone, 872,
    master - mean (870ms)  : 834, 907
     .   : milestone, 870,

Loading
gantt
    title Execution time (ms) HttpMessageHandler (.NET 6) 
    dateFormat  X
    axisFormat %s
    todayMarker off
    section Baseline
    This PR (6715) - mean (261ms)  : 257, 266
     .   : milestone, 261,
    master - mean (261ms)  : 257, 264
     .   : milestone, 261,

    section CallTarget+Inlining+NGEN
    This PR (6715) - mean (856ms)  : 822, 890
     .   : milestone, 856,
    master - mean (857ms)  : 825, 889
     .   : milestone, 857,

Loading

@andrewlock
Copy link
Member Author

andrewlock commented Feb 25, 2025

Benchmarks Report for tracer 🐌

Benchmarks for #6715 compared to master:

  • All benchmarks have the same speed
  • All benchmarks have the same allocations

The following thresholds were used for comparing the benchmark speeds:

  • Mann–Whitney U test with statistical test for significance of 5%
  • Only results indicating a difference greater than 10% and 0.3 ns are considered.

Allocation changes below 0.5% are ignored.

Benchmark details

Benchmarks.Trace.ActivityBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartStopWithChild net6.0 8.36μs 46.5ns 384ns 0.0159 0.00794 0 5.61 KB
master StartStopWithChild netcoreapp3.1 10.6μs 53ns 276ns 0.0198 0.00992 0 5.8 KB
master StartStopWithChild net472 16.4μs 49.3ns 191ns 1.03 0.304 0.0905 6.21 KB
#6715 StartStopWithChild net6.0 8.35μs 48.6ns 412ns 0.0124 0.00825 0 5.61 KB
#6715 StartStopWithChild netcoreapp3.1 10.5μs 60.3ns 430ns 0.0206 0.00514 0 5.8 KB
#6715 StartStopWithChild net472 16.4μs 43.6ns 169ns 1.03 0.289 0.0964 6.21 KB
Benchmarks.Trace.AgentWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 505μs 227ns 849ns 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 638μs 300ns 1.16μs 0 0 0 2.7 KB
master WriteAndFlushEnrichedTraces net472 843μs 706ns 2.73μs 0.417 0 0 3.3 KB
#6715 WriteAndFlushEnrichedTraces net6.0 504μs 349ns 1.26μs 0 0 0 2.7 KB
#6715 WriteAndFlushEnrichedTraces netcoreapp3.1 674μs 296ns 1.11μs 0 0 0 2.7 KB
#6715 WriteAndFlushEnrichedTraces net472 846μs 441ns 1.65μs 0.422 0 0 3.3 KB
Benchmarks.Trace.AspNetCoreBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendRequest net6.0 134μs 342ns 1.33μs 0.196 0 0 14.47 KB
master SendRequest netcoreapp3.1 149μs 198ns 766ns 0.222 0 0 17.27 KB
master SendRequest net472 0.000207ns 0.000164ns 0.000634ns 0 0 0 0 b
#6715 SendRequest net6.0 132μs 539ns 2.09μs 0.195 0 0 14.47 KB
#6715 SendRequest netcoreapp3.1 152μs 133ns 515ns 0.153 0 0 17.27 KB
#6715 SendRequest net472 0.000269ns 0.000209ns 0.00078ns 0 0 0 0 b
Benchmarks.Trace.CIVisibilityProtocolWriterBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master WriteAndFlushEnrichedTraces net6.0 544μs 2.79μs 12.5μs 0.546 0 0 41.64 KB
master WriteAndFlushEnrichedTraces netcoreapp3.1 678μs 3.56μs 21μs 0.342 0 0 41.65 KB
master WriteAndFlushEnrichedTraces net472 868μs 3.09μs 12μs 8.45 2.53 0.422 53.29 KB
#6715 WriteAndFlushEnrichedTraces net6.0 562μs 3.06μs 17.6μs 0.295 0 0 41.61 KB
#6715 WriteAndFlushEnrichedTraces netcoreapp3.1 720μs 4.1μs 29μs 0.355 0 0 41.81 KB
#6715 WriteAndFlushEnrichedTraces net472 848μs 3.97μs 14.9μs 8.39 2.52 0.419 53.35 KB
Benchmarks.Trace.DbCommandBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteNonQuery net6.0 1.44μs 1.3ns 5.03ns 0.0144 0 0 1.02 KB
master ExecuteNonQuery netcoreapp3.1 1.72μs 1.16ns 4.49ns 0.0138 0 0 1.02 KB
master ExecuteNonQuery net472 2.09μs 2.55ns 9.87ns 0.157 0.00104 0 987 B
#6715 ExecuteNonQuery net6.0 1.47μs 1.69ns 6.55ns 0.0139 0 0 1.02 KB
#6715 ExecuteNonQuery netcoreapp3.1 1.73μs 1.87ns 6.98ns 0.0132 0 0 1.02 KB
#6715 ExecuteNonQuery net472 2.15μs 2.31ns 8.63ns 0.156 0.00107 0 987 B
Benchmarks.Trace.ElasticsearchBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master CallElasticsearch net6.0 1.26μs 0.444ns 1.66ns 0.0139 0 0 976 B
master CallElasticsearch netcoreapp3.1 1.57μs 1.09ns 4.23ns 0.0128 0 0 976 B
master CallElasticsearch net472 2.47μs 1.78ns 6.89ns 0.157 0 0 995 B
master CallElasticsearchAsync net6.0 1.3μs 0.939ns 3.64ns 0.0132 0 0 952 B
master CallElasticsearchAsync netcoreapp3.1 1.66μs 4.42ns 17.1ns 0.014 0 0 1.02 KB
master CallElasticsearchAsync net472 2.76μs 15.3ns 99.3ns 0.167 0 0 1.05 KB
#6715 CallElasticsearch net6.0 1.3μs 0.485ns 1.82ns 0.0139 0 0 976 B
#6715 CallElasticsearch netcoreapp3.1 1.48μs 0.906ns 3.51ns 0.0135 0 0 976 B
#6715 CallElasticsearch net472 2.71μs 1.48ns 5.56ns 0.158 0 0 995 B
#6715 CallElasticsearchAsync net6.0 1.24μs 0.512ns 1.98ns 0.0136 0 0 952 B
#6715 CallElasticsearchAsync netcoreapp3.1 1.59μs 0.799ns 2.99ns 0.0135 0 0 1.02 KB
#6715 CallElasticsearchAsync net472 2.76μs 2.35ns 9.08ns 0.167 0 0 1.05 KB
Benchmarks.Trace.GraphQLBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master ExecuteAsync net6.0 1.26μs 1.1ns 4.26ns 0.0133 0 0 952 B
master ExecuteAsync netcoreapp3.1 1.64μs 0.656ns 2.54ns 0.0123 0 0 952 B
master ExecuteAsync net472 1.83μs 2.18ns 8.16ns 0.145 0 0 915 B
#6715 ExecuteAsync net6.0 1.31μs 0.551ns 2.14ns 0.0131 0 0 952 B
#6715 ExecuteAsync netcoreapp3.1 1.67μs 1.11ns 4.02ns 0.0124 0 0 952 B
#6715 ExecuteAsync net472 1.84μs 0.615ns 2.3ns 0.145 0 0 915 B
Benchmarks.Trace.HttpClientBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendAsync net6.0 4.36μs 1.89ns 7.07ns 0.0305 0 0 2.31 KB
master SendAsync netcoreapp3.1 5.4μs 2.49ns 8.98ns 0.0381 0 0 2.85 KB
master SendAsync net472 7.52μs 1.99ns 7.7ns 0.493 0 0 3.12 KB
#6715 SendAsync net6.0 4.45μs 1.19ns 4.28ns 0.0308 0 0 2.31 KB
#6715 SendAsync netcoreapp3.1 5.17μs 2.03ns 7.88ns 0.0362 0 0 2.85 KB
#6715 SendAsync net472 7.45μs 2.02ns 7.82ns 0.492 0 0 3.12 KB
Benchmarks.Trace.ILoggerBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 1.48μs 1.18ns 4.4ns 0.0231 0 0 1.64 KB
master EnrichedLog netcoreapp3.1 2.14μs 1.41ns 5.27ns 0.0225 0 0 1.64 KB
master EnrichedLog net472 2.59μs 0.989ns 3.83ns 0.249 0 0 1.57 KB
#6715 EnrichedLog net6.0 1.45μs 4.89ns 18.3ns 0.0227 0 0 1.64 KB
#6715 EnrichedLog netcoreapp3.1 2.21μs 1.55ns 5.78ns 0.0221 0 0 1.64 KB
#6715 EnrichedLog net472 2.65μs 1.63ns 6.33ns 0.249 0 0 1.57 KB
Benchmarks.Trace.Log4netBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 113μs 303ns 1.17μs 0.0561 0 0 4.28 KB
master EnrichedLog netcoreapp3.1 117μs 194ns 752ns 0.0584 0 0 4.28 KB
master EnrichedLog net472 150μs 174ns 673ns 0.674 0.225 0 4.46 KB
#6715 EnrichedLog net6.0 113μs 181ns 702ns 0.0553 0 0 4.28 KB
#6715 EnrichedLog netcoreapp3.1 116μs 126ns 487ns 0.0578 0 0 4.28 KB
#6715 EnrichedLog net472 148μs 168ns 652ns 0.665 0.222 0 4.46 KB
Benchmarks.Trace.NLogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 3.02μs 1.07ns 4.16ns 0.0302 0 0 2.2 KB
master EnrichedLog netcoreapp3.1 4.24μs 1.53ns 5.52ns 0.0295 0 0 2.2 KB
master EnrichedLog net472 4.77μs 1.19ns 4.59ns 0.32 0 0 2.02 KB
#6715 EnrichedLog net6.0 2.97μs 0.998ns 3.87ns 0.0313 0 0 2.2 KB
#6715 EnrichedLog netcoreapp3.1 4.28μs 1.38ns 5.16ns 0.03 0 0 2.2 KB
#6715 EnrichedLog net472 4.95μs 1.66ns 6.44ns 0.321 0 0 2.02 KB
Benchmarks.Trace.RedisBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master SendReceive net6.0 1.37μs 1.41ns 5.29ns 0.0157 0 0 1.14 KB
master SendReceive netcoreapp3.1 1.85μs 0.696ns 2.6ns 0.0154 0 0 1.14 KB
master SendReceive net472 2.11μs 0.966ns 3.62ns 0.183 0 0 1.16 KB
#6715 SendReceive net6.0 1.44μs 1.72ns 6.65ns 0.0158 0 0 1.14 KB
#6715 SendReceive netcoreapp3.1 1.8μs 5.29ns 20.5ns 0.0158 0 0 1.14 KB
#6715 SendReceive net472 2.02μs 0.337ns 1.3ns 0.183 0 0 1.16 KB
Benchmarks.Trace.SerilogBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master EnrichedLog net6.0 2.98μs 7.79ns 30.2ns 0.0224 0 0 1.6 KB
master EnrichedLog netcoreapp3.1 4μs 21.5ns 191ns 0.0216 0 0 1.65 KB
master EnrichedLog net472 4.24μs 3.85ns 14.9ns 0.323 0 0 2.04 KB
#6715 EnrichedLog net6.0 2.92μs 0.968ns 3.62ns 0.022 0 0 1.6 KB
#6715 EnrichedLog netcoreapp3.1 3.83μs 1.41ns 5.09ns 0.0209 0 0 1.65 KB
#6715 EnrichedLog net472 4.4μs 2.14ns 8.3ns 0.324 0 0 2.04 KB
Benchmarks.Trace.SpanBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master StartFinishSpan net6.0 391ns 0.0751ns 0.281ns 0.00803 0 0 576 B
master StartFinishSpan netcoreapp3.1 557ns 0.74ns 2.77ns 0.00778 0 0 576 B
master StartFinishSpan net472 654ns 0.214ns 0.802ns 0.0916 0 0 578 B
master StartFinishScope net6.0 507ns 0.171ns 0.662ns 0.00968 0 0 696 B
master StartFinishScope netcoreapp3.1 723ns 0.435ns 1.63ns 0.00908 0 0 696 B
master StartFinishScope net472 883ns 0.236ns 0.852ns 0.104 0 0 658 B
#6715 StartFinishSpan net6.0 405ns 0.158ns 0.591ns 0.00812 0 0 576 B
#6715 StartFinishSpan netcoreapp3.1 567ns 0.445ns 1.73ns 0.00793 0 0 576 B
#6715 StartFinishSpan net472 661ns 0.243ns 0.942ns 0.0917 0 0 578 B
#6715 StartFinishScope net6.0 496ns 0.3ns 1.16ns 0.00988 0 0 696 B
#6715 StartFinishScope netcoreapp3.1 767ns 0.33ns 1.23ns 0.00919 0 0 696 B
#6715 StartFinishScope net472 840ns 1.02ns 3.83ns 0.104 0 0 658 B
Benchmarks.Trace.TraceAnnotationsBenchmark - Same speed ✔️ Same allocations ✔️

Raw results

Branch Method Toolchain Mean StdError StdDev Gen 0 Gen 1 Gen 2 Allocated
master RunOnMethodBegin net6.0 713ns 0.326ns 1.26ns 0.00963 0 0 696 B
master RunOnMethodBegin netcoreapp3.1 988ns 0.439ns 1.7ns 0.00942 0 0 696 B
master RunOnMethodBegin net472 1.03μs 0.187ns 0.724ns 0.104 0 0 658 B
#6715 RunOnMethodBegin net6.0 688ns 0.26ns 1.01ns 0.0096 0 0 696 B
#6715 RunOnMethodBegin netcoreapp3.1 910ns 0.656ns 2.45ns 0.00924 0 0 696 B
#6715 RunOnMethodBegin net472 1.05μs 0.188ns 0.703ns 0.105 0 0 658 B

Base automatically changed from andrew/win-ssi/integration-tests to master March 12, 2025 09:27
@andrewlock andrewlock requested a review from a team as a code owner March 12, 2025 09:27
@andrewlock andrewlock force-pushed the andrew/win-ssi/update-gac-uninstaller branch from 4690b10 to 4d48037 Compare March 12, 2025 09:40
@andrewlock andrewlock merged commit 08caea5 into master Mar 12, 2025
63 of 64 checks passed
@andrewlock andrewlock deleted the andrew/win-ssi/update-gac-uninstaller branch March 12, 2025 14:15
@github-actions github-actions bot added this to the vNext-v3 milestone Mar 12, 2025
ddyurchenko pushed a commit that referenced this pull request Mar 31, 2025
…are already installed (#6715)

## Summary of changes

Fixes the issue of removing old GAC entries when there are multiple
assemblies in the GAC with the same name.

## Reason for change

#6714 highlighted an
issue with the GAC uninstall where we were _not_ removing the previous
`Datadog.Trace` entries during uninstall. This attempts to work around
that.

## Implementation details

Use another `Fusion` API to enumerate all the "Datadog.Trace"
assemblies, to get their fullnames (e.g. `Datadog.Trace,
Version=3.12.0.0, Culture=neutral, PublicKeyToken=def86d061d0d2eeb,
processorArchitecture=MSIL`).

We then run the uninstall for _all_ of the GAC assemblies we find. As
long as each assembly has been registered with a _different_ associated
filepath (i.e. the associated native loader for the gac'd file), then we
_should_ only ever remove a single file at most. The integration tests
demonstrate this works, even if it's a bit messy.

## Test coverage

Unskipped the previously skipped GAC tests, and they pass so 🤞 

## Other details

Initially I wanted to use `CreateInstallReferenceEnum()` to enumerate
the _actual_ references so that we could be sure we _only_ try to remove
the correct reference, but I couldn't get that to work (Getting an
HResult error 🤷‍♂️). The current approach appears to work though, so
maybe we should just consider that an optimisation for later? 🤷‍♂️ I
also haven't looked to see if we have any existing implementation of the
API...

Stacked on
- #6714

---------

Co-authored-by: Kevin Gosse <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants