RaptorDB-Document
RaptorDB-Document copied to clipboard
Inconsistency when consulting data
My APP logic is:
- Get data from an API
- Delete the current data in raptorDB
- Insert the data from the API in the DB
- use the data from the DB
Randomly I get different results from the DB when querying it. I've added some logs in the APP to try to understand it, since it doesn't happen in my machine but occurs repeatedly in the production machine.
2020-02-24 09:42:38.9950|TRACE|application.App|Plannings API: 2 (Amount of data returned from DB) 2020-02-24 09:42:38.9950|TRACE|application.App|Plannings DB: 2 (Querying the data from the DB) 2020-02-24 09:42:38.9950|TRACE|application.App|Plannings deleted: 2 (Data deleted from the DB) 2020-02-24 09:42:38.9950|TRACE|application.App|Plannings inserted: 2 (Data inserted from the DB) 2020-02-24 09:42:38.9950|TRACE|application.App|Plannings DB: 2 (Querying the DB just after the insert to check if the amount is the same) 2020-02-24 09:42:41.7042|TRACE|application.App|LoadPlanningCollaborateur -> Planning.Count: 2 (Checking the amount again) ... user interaction without changing DB ... 2020-02-24 09:43:51.2066|TRACE|application.App|LoadPlanningCollaborateur -> Planning.Count: 0 (Same query, same parameters, no data returned)
It can return sometimes one row.
here's my view
/// <summary>
/// View des plannings
/// </summary>
[RegisterView]
public class PlanningView : View<Planning>
{
public PlanningView()
{
this.isPrimaryList = true;
this.Name = nameof(PlanningView);
this.isActive = true;
this.BackgroundIndexing = false;
this.TransactionMode = true;
this.Schema = typeof(PlanningViewRowSchema);
this.Mapper = (IMapAPI api, Guid docid, Planning doc) => api.EmitObject(docid, doc);
this.Version = 2;
}
}
Querying the DB :
return DB.Query<PlanningViewRowSchema>(filter);
Saving to DB :
public Guid PutPlanning(Planning Planning)
{
if (Planning.DateCreation == DateTime.MinValue)
Planning.DateCreation = DateTime.Now;
if (DB.Save<PlanningViewRowSchema>(Planning.Id, PlanningViewRowSchema.FromPlanning(Planning)))
return Planning.Id;
else
return Guid.Empty;
}
Deleting from DB:
public int DeletePlannings(List<Planning> Plannings)
{
int count = 0;
foreach (var planning in Plannings)
{
if (DB.Delete(planning.Id))
count += 1;
}
return count;
}
I've tried changing the view parameters like using this.TransactionMode = true;
but it didn't change the results.
Any help is welcomed.
Also, at first I was interacting with the DB with the view model rather than the schema like :
DB.Save<Planning>(Planning.Id, Planning)
DB.Query<Planning>(filter);
Changing to the RowSchema seemed to work at first, but after more extensive testing the errors returned.
Is your prod server running on IIS?
No
How long before the inconsistencies occur in prod (since you don't see them in dev)?
Do you have multiple concurrent users in prod?
Can't say with certainty since it can work around while I'm doing some tests in prod, and then a couple of hours later when the user is gonna test we got the incosistencies.
No, single user.
Are the deletes done in parallel (is your application threaded)?
No, single threaded.
Are you on the latest build?
Yes, 4.0.9. My project targets net461 and netstandard2.1.