We discovered that this code in one of our web services sporadically throws NullReferenceException:

public class DataRepository : IDataRepository, IDisposable  
{
    private bool _disposed;
    private readonly IDbConnection _db;

    public DataRepository(IConfiguration configuration)
    {
        _configuration = configuration;
        _db = new SqlConnection(_configuration.ConnectionString);
    }

    public ClientAccess GetClientAccess(Guid clientId)
    {
        var parameters = new DynamicParameters();
        parameters.Add("@clientId", clientId);
        return _db.Query<ClientAccess>("GetClientAccess", parameters, commandType: CommandType.StoredProcedure).SingleOrDefault();
    }

    public void Dispose()
    {
       Dispose(true);
       GC.SuppressFinalize(this);
    }

    protected virtual void Dispose(bool disposing)
    {
        if (!_disposed)
        {
            if (disposing)
            {
                if (_db != null)
                {
                    _db.Close();          
                }
            }
            _disposed = true;
        }
    }     
}

And the stack trace was:

System.NullReferenceException: Object reference not set to an instance of an object.  
    at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
    at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
    at System.Data.SqlClient.SqlConnection.Open()
    at Dapper.SqlMapper.<QueryImpl>d__11`1.MoveNext()
    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction

The repository was injected into service with ServiceStack Funq:

container.Register <IDataRepository>(c => new DataRepository(new Configuration())));  

It turns out that by default in ServiceStack Funq IoC container objects have singleton scope and as a result, SqlConnection was opened when AppHost was started, was never closed and therefore SqlConnection was shared between all requests and threads.

The fix was simple change of scope:

container.Register <IDataRepository>(c => new DataRepository(new Configuration())).ReusedWithin(ReuseScope.Request);  

This fixed the problem, but more interesting question is why it was happening. According to MSDN SqlConnection is thread safe. There are no reasons of having SqlConnection in singleton since it is already pooled, but I am still not clear on whether it thread safe or no.