Skip to content

Commit

Permalink
Remove verification of datapoint deletes (#186)
Browse files Browse the repository at this point in the history
We once needed this, since timeseries were not immediately consistent, but that is no longer the case, and this adds additional complexity that we don't need.
  • Loading branch information
einarmo authored Aug 5, 2022
1 parent d38bb05 commit 7a302b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 51 deletions.
5 changes: 3 additions & 2 deletions Cognite.Extensions/DeleteError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public sealed class DeleteError
public IEnumerable<Identity> IdsNotFound { get; }

/// <summary>
/// Ids of time series with unconfirmed data point deletions
/// Ids of time series with unconfirmed data point deletions.
/// DEPRECATED, timeseries is now immediately consistent, and we no longer verify deletion.
/// </summary>
public IEnumerable<Identity> IdsDeleteNotConfirmed { get; }

Expand All @@ -23,7 +24,7 @@ public sealed class DeleteError
/// found or with unconfirmed deletions
/// </summary>
/// <param name="idsNotFound">Ids not found</param>
/// <param name="idsDeleteNotConfirmed">Mismatched ids</param>
/// <param name="idsDeleteNotConfirmed">Mismatched ids. DEPRECATED, leave empty.</param>
public DeleteError(IEnumerable<Identity> idsNotFound, IEnumerable<Identity> idsDeleteNotConfirmed)
{
IdsNotFound = idsNotFound;
Expand Down
43 changes: 1 addition & 42 deletions Cognite.Extensions/TimeSeries/DataPointExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -398,49 +398,8 @@ await generators.RunThrottled(
nameof(DeleteIgnoreErrorsAsync), ++taskNum, chunks.Count);
},
token).ConfigureAwait(false);
_logger.LogDebug("Deletion completed. Verifying that data points were removed from CDF");

var query = new List<DataPointsQueryItem>();
foreach (var kvp in ranges)
{
var queries = kvp.Value.Select(r =>
{
return new DataPointsQueryItem()
{
ExternalId = kvp.Key.ExternalId,
Id = kvp.Key.Id,
Start = $"{r.First.ToUnixTimeMilliseconds()}",
End = $"{r.Last.ToUnixTimeMilliseconds() + 1}",
Limit = 1
};
});
query.AddRange(queries);
}

var queryChunks = query
.ChunkBy(listChunkSize)
.ToList(); // Maximum number of items in the /timeseries/data/list endpoint.

var notVerified = new HashSet<Identity>();
var verifyGenerators = queryChunks
.Select<IEnumerable<DataPointsQueryItem>, Func<Task>>(
c => async () =>
{
var errors = await VerifyDataPointsDeletion(dataPoints, c, token).ConfigureAwait(false);
lock (mutex)
{
notVerified.UnionWith(errors);
}
});

taskNum = 0;
await verifyGenerators.RunThrottled(
listThrottleSize,
(_) => { _logger.LogDebug("Verifying data points deletion: {Num}/{Total}", ++taskNum, queryChunks.Count); },
token).ConfigureAwait(false);

_logger.LogDebug("Deletion tasks completed");
return new DeleteError(missing, notVerified);
return new DeleteError(missing, Enumerable.Empty<Identity>());
}

private static async Task<HashSet<Identity>> DeleteDataPointsIgnoreErrorsChunk(
Expand Down
8 changes: 1 addition & 7 deletions ExtractorUtils.Test/unit/DatapointsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public async Task TestDeleteDataPoints()
mockHttpMessageHandler.Protected()
.Verify<Task<HttpResponseMessage>>(
"SendAsync",
Times.Exactly(3), // 1 delete and two list
Times.Exactly(1), // 1 delete
ItExpr.IsAny<HttpRequestMessage>(),
ItExpr.IsAny<CancellationToken>());

Expand All @@ -195,8 +195,6 @@ public async Task TestDeleteDataPoints()

Assert.Contains(new Identity("missing-C"), errors.IdsNotFound);
Assert.Contains(new Identity("missing-F"), errors.IdsNotFound);
Assert.Contains(new Identity("nc-E"), errors.IdsDeleteNotConfirmed);
Assert.Contains(new Identity("nc-H"), errors.IdsDeleteNotConfirmed);
}

System.IO.File.Delete(path);
Expand Down Expand Up @@ -565,10 +563,6 @@ private static async Task<HttpResponseMessage> mockDeleteDataPointsAsync(HttpReq
var dp = new DataPointListItem();
dp.ExternalId = id;
dp.NumericDatapoints = new NumericDatapoints();
if (id.StartsWith("nc"))
{
dp.NumericDatapoints.Datapoints.Add(new NumericDatapoint{Timestamp = DateTime.UtcNow.ToUnixTimeMilliseconds(), Value = 1.0});
}
dpList.Items.Add(dp);
}
using(MemoryStream stream = new MemoryStream())
Expand Down

0 comments on commit 7a302b1

Please sign in to comment.