Skip to content

QueryForNonStaleData throwing OperationCanceledException when no documents of queried type exists #3976

@fgskmd

Description

@fgskmd

Im running into an issue when using QueryForNonStaleData. OperationCanceledException is thrown (after the provided timespan has occured) when no documents of the queried type/document exists. When i am using the IQuerySession.Query<T> method it works fine. After populating the database with an event of type MyReadModelCreatedEvent, the event is handled and my document is created. After the creation of the document, QueryForNonStaleData resolves inside the specified timespan and returns the created document.

This is my projection:

public class MyProjection : SingleStreamProjection<MyReadModel, string>
{
    public MyReadModel Create(IEvent<MyReadModelCreatedEvent> @event)
    {
        return new MyReadModel(/* creating object */)
    }
}
public class MyReadModelRepository(IQuerySession session) : IMyReadModelRepository
{
    public async Task<IReadOnlyList<MyReadModel>> GetMyReadModelForSomeIndex(string indexId, CancellationToken cancellationToken)
    {
        return await session
            .QueryForNonStaleData<MyReadModel>(5.Seconds())
            .Where(x => x.IndexId== indexId)
            .ToListAsync(cancellationToken);
    }
}

I have setup the following for the document:

options.Schema.For<MyReadModel>()
     .Identity(x => x.SomeId)
     .Index(x => x.IndexId);

Multi tenant is also set up with following settings:

options.Events.TenancyStyle = TenancyStyle.Conjoined;
options.Advanced.DefaultTenantUsageEnabled = false;
options.Policies.AllDocumentsAreMultiTenanted();
options.Policies.PartitionMultiTenantedDocumentsUsingMartenManagement("mySchema");

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