Skip to content

Commit a21ee5e

Browse files
kayvontadjKayvon Tadj
andauthored
cloned relatedContext to prevent concurrent access to Collection (#204)
* 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]>
1 parent 170f127 commit a21ee5e

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.pipelines/azure-pipelines-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ resources:
1616
options: --entrypoint=""
1717

1818
variables:
19-
VcVersion : 1.11.9
19+
VcVersion : 1.11.10
2020
ROOT: $(Build.SourcesDirectory)
2121
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2222
ENABLE_PRS_DELAYSIGN: 1

.pipelines/azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pool:
1818
vmImage: windows-latest
1919

2020
variables:
21-
VcVersion : 1.11.9
21+
VcVersion : 1.11.10
2222
ROOT: $(Build.SourcesDirectory)
2323
CDP_DEFINITION_BUILD_COUNT: $[counter('', 0)] # needed for onebranch.pipeline.version task https://aka.ms/obpipelines/versioning
2424
ENABLE_PRS_DELAYSIGN: 1

src/VirtualClient/VirtualClient.Actions/Memtier/MemtierBenchmarkClientExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ private Task ExecuteWorkloadsAsync(IPAddress serverIPAddress, ServerState server
383383
}
384384

385385
commands.Add(commandArguments);
386-
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext, cancellationToken));
386+
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext.Clone(), cancellationToken));
387387

388388
if (this.WarmUp)
389389
{

src/VirtualClient/VirtualClient.Actions/Redis/RedisBenchmarkClientExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ private Task ExecuteWorkloadsAsync(IPAddress serverIPAddress, ServerState server
278278
string commandArguments = $"-c \"{this.RedisExecutablePath} -h {serverIPAddress} -p {serverPort} {this.CommandLine}\"";
279279
commands.Add($"{command} {commandArguments}");
280280

281-
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext, cancellationToken));
281+
workloadProcesses.Add(this.ExecuteWorkloadAsync(serverPort, command, commandArguments, workingDirectory, relatedContext.Clone(), cancellationToken));
282282

283283
if (this.WarmUp)
284284
{

src/VirtualClient/VirtualClient.Contracts/Metadata/MetadataContract.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class MetadataContract
2828
/// </summary>
2929
private static IDictionary<string, IDictionary<string, object>> persistedMetadata = new ConcurrentDictionary<string, IDictionary<string, object>>(StringComparer.OrdinalIgnoreCase);
3030

31+
private readonly object lockObject = new object();
32+
3133
/// <summary>
3234
/// Metadata properties for an instance of the metadata contract typically associated with
3335
/// an individual VC component lifetime.
@@ -169,11 +171,14 @@ public static void ResetPersisted()
169171
/// <param name="telemetryContext">The telemetry event context to which the metadata contract should be applied.</param>
170172
public void Apply(EventContext telemetryContext)
171173
{
172-
MetadataContract.ApplyMetadata(telemetryContext, MetadataContract.persistedMetadata);
174+
lock (this.lockObject)
175+
{
176+
MetadataContract.ApplyMetadata(telemetryContext, MetadataContract.persistedMetadata);
173177

174-
// Component-scope properties take precedence over global properties in the case that there
175-
// is a conflict. Any existing global properties will be overridden in the case of a conflict.
176-
MetadataContract.ApplyMetadata(telemetryContext, this.instanceMetadata);
178+
// Component-scope properties take precedence over global properties in the case that there
179+
// is a conflict. Any existing global properties will be overridden in the case of a conflict.
180+
MetadataContract.ApplyMetadata(telemetryContext, this.instanceMetadata);
181+
}
177182
}
178183

179184
/// <summary>

0 commit comments

Comments
 (0)