Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency when consulting data #19

Open
frohlichcortezh opened this issue Feb 24, 2020 · 9 comments
Open

Inconsistency when consulting data #19

frohlichcortezh opened this issue Feb 24, 2020 · 9 comments

Comments

@frohlichcortezh
Copy link

My APP logic is:

  1. Get data from an API
  2. Delete the current data in raptorDB
  3. Insert the data from the API in the DB
  4. 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.

@frohlichcortezh
Copy link
Author

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.

@mgholam
Copy link
Owner

mgholam commented Feb 24, 2020

Is your prod server running on IIS?

@frohlichcortezh
Copy link
Author

No

@mgholam
Copy link
Owner

mgholam commented Feb 24, 2020

How long before the inconsistencies occur in prod (since you don't see them in dev)?

Do you have multiple concurrent users in prod?

@frohlichcortezh
Copy link
Author

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.

@mgholam
Copy link
Owner

mgholam commented Feb 24, 2020

Are the deletes done in parallel (is your application threaded)?

@frohlichcortezh
Copy link
Author

No, single threaded.

@mgholam
Copy link
Owner

mgholam commented Feb 24, 2020

Are you on the latest build?

@frohlichcortezh
Copy link
Author

Yes, 4.0.9.
My project targets net461 and netstandard2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants