Skip to content
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

Versioning_Engine: Adding lock around the upgrader loop in the ToNewVersion method. #2941

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions Versioning_Engine/Convert/ToNewVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,38 +83,40 @@ public static BsonDocument ToNewVersion(this BsonDocument document, string versi
// Get the list of upgraders to call
List<string> versions = Query.UpgradersToCall(version);

// Call all the upgraders in sequence
for (int i = 0; i < versions.Count; i++)
lock (m_versioningLock)
{
// Create a connection with the upgrader
NamedPipeServerStream pipe = GetPipe(versions[i]);
if (pipe == null)
return document;
// Call all the upgraders in sequence
for (int i = 0; i < versions.Count; i++)
{
// Create a connection with the upgrader
NamedPipeServerStream pipe = GetPipe(versions[i]);
if (pipe == null)
return document;

// Send the document
SendDocument(document, pipe);
// Send the document
SendDocument(document, pipe);

// Get the new version back
BsonDocument result = ReadDocument(pipe);
if (result != null)
{
if (result.Contains("_t") && result["_t"] == "NoUpdate")
// Get the new version back
BsonDocument result = ReadDocument(pipe);
if (result != null)
{
if (result.Contains("Message"))
if (result.Contains("_t") && result["_t"] == "NoUpdate")
{
noUpdateMessage = result["Message"].ToString();
Engine.Base.Compute.RecordError(noUpdateMessage);
}
}
else if (document != result)
{
wasUpdated = true;
document = result;
}
}
if (result.Contains("Message"))
{
noUpdateMessage = result["Message"].ToString();
Engine.Base.Compute.RecordError(noUpdateMessage);
}
}
else if (document != result)
{
wasUpdated = true;
document = result;
}
}
}
}


// Record the fact that a document needed to be upgraded
if (wasUpdated || noUpdateMessage != null)
{
Expand Down Expand Up @@ -234,6 +236,8 @@ private static BsonDocument ReadDocument(PipeStream pipe)

private static Dictionary<string, NamedPipeServerStream> m_Pipes = new Dictionary<string, NamedPipeServerStream>();

private static object m_versioningLock = new object();

/***************************************************/
}
}
Expand Down