We're currently developing a solution for a client and have moved from running on local development machines only to RavenHQ yesterday.
The only difference in environments is that locally we ran RavenDB in development mode as a single instance of the native window service, and on RavenHQ we use the "High Performance" plan with replication.
Our is a simple restful WEBAPI application, that uses 19 indices and a few document types ( its basically a proxy for the old internal service our client had that could not cope with the load )
Now to our problem: One endpoint only for our application randomly ( in about 90 % of cases ) returns zero results ( even though there are actually about a 1000 matching entries, manually verified )
However from time to time the query succeeds and returns normal results.....
This only happens in the replicated environment not the local single machine one.....
I tried to diagnose as much as i could, in the replicated server setup: All documents are properly replicated, all indices are non stale and valid, and there are no errors anywhere. This is true for both servers. ( because at first i thought replication was not working and sometimes we would return invalid results from a secondary server ) but all seems fine to me.....
Here is the relevant document:
public class Leaflet
{
public string Id { get; set; }
public DateTime CreatedOn { get; set; }
public DateTime UpdatedOn { get; set; }
public string Name { get; set; }
public string IndustryId { get; set; }
public string IndustryName { get; set; }
public string RetailerId { get; set; }
public string RetailerName { get; set; }
public string RegionId { get; set; }
public string RegionName { get; set; }
public DateTime ValidFrom { get; set; }
public DateTime ValidTo { get; set; }
public DateTime TimeStamp { get; set; }
public int TotalPages { get; set; }
public bool IsPromoted { get; set; }
public bool IsTagged { get; set; }
public string ImageBasePath { get; set; }
public string PreviewImageLink { get; set; }
public int[] PreviewImageSize { get; set; }
public string ShareLink { get; set; }
}
( please note the model is not very good, because it has to satisfy strange legacy requirements )
The index definition is:
public class LeafletSearchIndex : AbstractIndexCreationTask<Leaflet,LeafletIndexEntry>
{
public LeafletSearchIndex()
{
Map = leaflets => leaflets.Select(l => new
{
l.Name,
l.IndustryId,
l.IndustryName,
l.RetailerId,
l.RetailerName,
l.RegionId,
l.RegionName,
l.ValidFrom,
l.ValidTo,
l.TimeStamp,
l.TotalPages,
l.IsPromoted,
PromotionOrder = l.IsPromoted ? 1 : 0,
FullText = new[]
{
l.Name,
l.IndustryName,
l.RetailerName
}
});
Index(c => c.FullText,FieldIndexing.Analyzed);
}
}
public class LeafletIndexEntry : Leaflet
{
public int PromotionOrder { get; set; }
public IEnumerable<string> FullText { get; set; }
}
And one of the failing queries looks like this:
var regionIds = new ["Region/
2147483647", "Region/4", "Region/12", "Region/13", "Region/16", "Region/17", "Region/19", "Region/20", "Region/21"]; // Note this is extracted and dynamically generated normally...... but our diagnostics logging provides me with the information so i pasted it here
RavenQueryStatistics statistics1 = null;
var topLeaflets = await session.Query<LeafletIndexEntry, LeafletSearchIndex>()
.Statistics(out statistics1)
.Where(l => l.IsPromoted)
.TimeContrainedByDay()
.OrderByDescending(l => l.TimeStamp)
.As<Leaflet>()
.Take(1024)
.ToListAsync().ConfigureAwait(false);
LogQueryResult("TopLeaflets", statistics1, topLeaflets);
The query log ( LogQueryResult )
"TopLeaflets": 0, statistics RavenQueryStatistics { IsStale: False, DurationMilliseconds: 8, TotalResults: 0, SkippedResults: 0, Timestamp: 03/26/2015 20:44:33, IndexName: "LeafletSearchIndex", IndexTimestamp: 03/26/2015 20:44:33, IndexEtag: Etag { Restarts: 72057594037927937, Changes: 361398 }, NonAuthoritativeInformation: False, LastQueryTime: 01/01/0001 00:00:00, TimingsInMilliseconds: [], ResultSize: 456, ScoreExplanations: [] }
The only thing that looks of to me are the TimingsInMilliseconds and the LastQueryTime ( since the query has been executed before without client restarts ) ....
Anybody has an idea what could be going wrong here ????