Skip to content

No exception, but select count(1) returns empty resultset #995

Description

@kwaazaar

I execute a query which returns a count, similar to "select count(1) from mytable". In my opinion this query should always return a resultset with one row OR throw an exception.

In my production logs I now see that under heavy load the QueryAsync sometimes returns an empty resultset (at the same time the log also shows connection errors/timeouts for other parallel requests).

I use this code:

protected virtual async Task<IEnumerable> TranQueryAsync(string query, object param)
{
return await _conn.QueryAsync(query, param, _runningTransaction, 30).ConfigureAwait(false);
}

My code calls First() on the resulting IEnumerable, but I get the exception that the sequence contains no elements. I think this is not ok and the QueryAsync should have thrown an exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions