Skip to content

Commit

Permalink
cloned relatedContext to prevent concurrent access to Collection (#204)
Browse files Browse the repository at this point in the history
* cloned relatedContext to prevent concurrent access to Collection

* updated Redis to clone telemetry and locked Apply method for concurrent collection

---------

Co-authored-by: Kayvon Tadj <[email protected]>
  • Loading branch information
kayvontadj and Kayvon Tadj authored Nov 7, 2023
1 parent 170f127 commit a21ee5e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pipelines/azure-pipelines-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resources:
options: --entrypoint=""

variables:
VcVersion : 1.11.9
VcVersion : 1.11.10
ROOT: $(Build.SourcesDirectory)
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
ENABLE_PRS_DELAYSIGN: 1
Expand Down
2 changes: 1 addition & 1 deletion .pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pool:
vmImage: windows-latest

variables:
VcVersion : 1.11.9
VcVersion : 1.11.10
ROOT: $(Build.SourcesDirectory)
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
ENABLE_PRS_DELAYSIGN: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private Task ExecuteWorkloadsAsync(IPAddress serverIPAddress, ServerState server
}
commands.Add(commandArguments);
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext, cancellationToken));
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext.Clone(), cancellationToken));
if (this.WarmUp)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ private Task ExecuteWorkloadsAsync(IPAddress serverIPAddress, ServerState server
string commandArguments = $"-c \"{this.RedisExecutablePath} -h {serverIPAddress} -p {serverPort} {this.CommandLine}\"";
commands.Add($"{command} {commandArguments}");
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext, cancellationToken));
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext.Clone(), cancellationToken));
if (this.WarmUp)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class MetadataContract
/// </summary>
private static IDictionary<string, IDictionary<string, object>> persistedMetadata = new ConcurrentDictionary<string, IDictionary<string, object>>(StringComparer.OrdinalIgnoreCase);

private readonly object lockObject = new object();

/// <summary>
/// Metadata properties for an instance of the metadata contract typically associated with
/// an individual VC component lifetime.
Expand Down Expand Up @@ -169,11 +171,14 @@ public static void ResetPersisted()
/// <param name="telemetryContext">The telemetry event context to which the metadata contract should be applied.</param>
public void Apply(EventContext telemetryContext)
{
MetadataContract.ApplyMetadata(telemetryContext, MetadataContract.persistedMetadata);
lock (this.lockObject)
{
MetadataContract.ApplyMetadata(telemetryContext, MetadataContract.persistedMetadata);

// Component-scope properties take precedence over global properties in the case that there
// is a conflict. Any existing global properties will be overridden in the case of a conflict.
MetadataContract.ApplyMetadata(telemetryContext, this.instanceMetadata);
// Component-scope properties take precedence over global properties in the case that there
// is a conflict. Any existing global properties will be overridden in the case of a conflict.
MetadataContract.ApplyMetadata(telemetryContext, this.instanceMetadata);
}
}

/// <summary>
Expand Down

0 comments on commit a21ee5e

Please sign in to comment.