Skip to content

Commit

Permalink
Increase timeout updating db for person and induction sync
Browse files Browse the repository at this point in the history
Increased timeout to 5 mins

Increased timeout to 20 minutes

Added more logging to try and troubleshoot timeout

Tweak to logging

temporary workaround failing record
  • Loading branch information
hortha committed Feb 4, 2025
1 parent 789ac72 commit d26daf9
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ public async Task<IReadOnlyCollection<Guid>> SyncPersonsAsync(
bool dryRun,
CancellationToken cancellationToken = default)
{
var toSync = persons.ToList();
// Temporary workaround for a specific record that's causing issues in pre-prod
var toSync = persons.Where(p => p.PersonId != Guid.Parse("52ab23df-903a-eb11-a813-000d3aadc093")).ToList();

if (ignoreInvalid)
{
Expand Down Expand Up @@ -335,6 +336,7 @@ public async Task<IReadOnlyCollection<Guid>> SyncPersonsAsync(
using (var mergeCommand = connection.CreateCommand())
{
mergeCommand.CommandText = modelTypeSyncInfo.UpsertStatement;
mergeCommand.CommandTimeout = 120;
mergeCommand.Parameters.Add(new NpgsqlParameter(NowParameterName, clock.UtcNow));
mergeCommand.Transaction = txn;
await mergeCommand.ExecuteNonQueryAsync();
Expand Down Expand Up @@ -369,6 +371,11 @@ public async Task<IReadOnlyCollection<Guid>> SyncPersonsAsync(

return await SyncPersonsAsync(personsExceptFailedOne, eventsExceptFailedOne, ignoreInvalid, dryRun, cancellationToken);
}
catch (Exception ex)
{
logger.LogWarning($"Exception {ex.Message} attempting to sync persons with IDs [{string.Join(", ", toSync.Select(p => p.DqtContactId))}].");
throw;
}

await txn.SaveEventsAsync(events, "events_person_import", clock, cancellationToken, timeoutSeconds: 120);

Expand Down Expand Up @@ -490,6 +497,7 @@ private async Task<int> SyncInductionsAsync(
using (var mergeCommand = connection.CreateCommand())
{
mergeCommand.CommandText = modelTypeSyncInfo.UpsertStatement;
mergeCommand.CommandTimeout = 120;
mergeCommand.Parameters.Add(new NpgsqlParameter(NowParameterName, clock.UtcNow));
mergeCommand.Transaction = txn;
using var reader = await mergeCommand.ExecuteReaderAsync();
Expand Down

0 comments on commit d26daf9

Please sign in to comment.