Skip to content

Commit ba2d6bb

Browse files
Merge pull request #70 from sandeepsnairms/main
Job active flag not getting reset ifcheck CS enabled fails
2 parents 71df7e0 + d45be74 commit ba2d6bb

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

MongoMigrationWebApp/Shared/MainLayout.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<main>
77
<div class="top-row px-4 d-flex justify-content-between align-items-center">
88
<h2 class="text-left">Migrate to Azure Cosmos DB for MongoDB (vCore based)</h2>
9-
<div class="ms-2 small">v0.7.7</div>
9+
<div class="ms-2 small">v0.7.9</div>
1010
</div>
1111

1212
<article class="content px-4">

OnlineMongoMigrationProcessor/Helpers/MongoHelper.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ public static long GetDocumentCount(IMongoCollection<BsonDocument> collection, F
138138
{
139139
Log.WriteLine($"Error checking for change streams: {ex.ToString()}", LogType.Error);
140140
Log.Save();
141-
return (IsCSEnabled: false, Version: version);
141+
//return (IsCSEnabled: false, Version: version);
142+
throw ex;
142143
}
143144
}
144145

OnlineMongoMigrationProcessor/MigrationWorker.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -266,17 +266,6 @@ public async Task StartMigrationAsync(MigrationJob job, string sourceConnectionS
266266
{
267267
Log.WriteLine($"Attempt {attempts} failed due to timeout: {ex.ToString()}. Details:{ex.ToString()}", LogType.Error);
268268

269-
if (attempts >= maxRetries)
270-
{
271-
Log.WriteLine("Maximum retry attempts reached. Aborting operation.", LogType.Error);
272-
Log.Save();
273-
274-
_job.CurrentlyActive = false;
275-
_jobs?.Save();
276-
277-
_migrationProcessor?.StopProcessing();
278-
}
279-
280269
Log.WriteLine($"Retrying in {backoff.TotalSeconds} seconds...", LogType.Error);
281270
Thread.Sleep(backoff);
282271
Log.Save();
@@ -286,16 +275,29 @@ public async Task StartMigrationAsync(MigrationJob job, string sourceConnectionS
286275
}
287276
catch (Exception ex)
288277
{
289-
Log.WriteLine(ex.ToString(), LogType.Error);
290-
Log.Save();
278+
Log.WriteLine($"Attempt {attempts} failed: {ex.ToString()}. Details:{ex.ToString()}", LogType.Error);
291279

292-
_job.CurrentlyActive = false;
293-
_jobs?.Save();
294-
continueProcessing = false;
280+
Log.WriteLine($"Retrying in {backoff.TotalSeconds} seconds...", LogType.Error);
281+
Thread.Sleep(backoff);
282+
Log.Save();
295283

296-
_migrationProcessor?.StopProcessing();
284+
continueProcessing = true;
285+
//backoff = TimeSpan.FromTicks(backoff.Ticks * 2);
286+
297287
}
298288
}
289+
if (attempts == maxRetries)
290+
{
291+
Log.WriteLine("Maximum retry attempts reached. Aborting operation.", LogType.Error);
292+
Log.Save();
293+
294+
_job.CurrentlyActive = false;
295+
_jobs?.Save();
296+
continueProcessing = false;
297+
298+
_migrationProcessor?.StopProcessing();
299+
300+
}
299301
}
300302

301303
private async Task<List<MigrationChunk>> PartitionCollection(string databaseName, string collectionName, string idField = "_id")

OnlineMongoMigrationProcessor/Processors/CopyProcessor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public void Migrate(MigrationUnit item, string sourceConnectionString, string ta
195195
{
196196
_job.CurrentlyActive = false;
197197
_jobs?.Save();
198+
ProcessRunning = false;
198199
}
199200
}
200201
else

OnlineMongoMigrationProcessor/Processors/MongoDocumentCopier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public async Task<bool> CopyDocumentsAsync(
166166
var gte = bounds.gte;
167167
var lt = bounds.lt;
168168

169-
Log.WriteLine($"Document copy for chunk[{ migrationChunkIndex}], couting documents on target");
169+
Log.WriteLine($"Document copy for chunk[{ migrationChunkIndex}], counting documents on target");
170170
Log.Save();
171171

172172
try

0 commit comments

Comments
 (0)