coronabytes / dotnet-arangodb

.NET Driver for ArangoDB
Apache License 2.0
67 stars 18 forks source link

Update Document Null Reference Exception #72

Closed michel-pi closed 3 days ago

michel-pi commented 1 week ago

This happens inside this library under huge system load. Due to the load, no more http requests can be processed.

We receive a null value as the result from SendAsync or SendContentAsync. This leads to a crash in "ArangoDocumentModule.cs" in "UpdateAsync":

See comment:

var res = await UpdateManyAsync<T, ArangoVoid>(database, collection,
    new List<T> { doc }, waitForSync, keepNull, mergeObjects,
    returnOld, returnNew, silent, ignoreRevs, exclusive, cancellationToken).ConfigureAwait(false);

return res.SingleOrDefault(); // res is null!
coronabytes commented 1 week ago

hmm, maybe your arangodb version does not send an error code on "overload" it shoud be handled by this.

var res = await _httpClient.SendAsync(msg, cancellationToken).ConfigureAwait(false);

if (!res.IsSuccessStatusCode)
    if (throwOnError)
    {
        var errorContent = await res.Content.ReadAsStringAsync().ConfigureAwait(false);
        var error = _configuration.Serializer.Deserialize<ErrorResponse>(errorContent);
        throw new ArangoException(errorContent, error.ErrorMessage,
            (HttpStatusCode) error.Code, (ArangoErrorCode) error.ErrorNum);
    }
    else
    {
        return default;
    }
michel-pi commented 3 days ago

This is a really odd edge case, not related to the library. It's about limited system resources, socket exhaustion or something alike, which causes undefined behavior. No need to worry.

We will investigate and i will create PR's as needed