Skip to content

Review update mechanisms: triggers, queue and local storage #27

@timgdavies

Description

@timgdavies

In addition to the locking issues in #26 we are experiencing a few unexplained bugs leading to:

Duplicated Entries

Expected behaviour: The frontend application fetches the questions and answers. Where an answer already exists, then changes to that question should trigger updateRow using the ID of the entry in the database to update the record.

Observed behaviour: In some cases, we appear to have bulk writes coming through the API to Insert new blank records for questions that already had answers. This creates duplicate survey_data entries for a given question, and the blank one with a higher ID ends up returned when the survey is next loaded - appearing to create data loss to the user.

Notably, the later entries appear to include no data, but include the privatenotes and justification fields (even when these are not enabled for the question).

Earlier entry:

{'example0': '', 'example1': '', 'example2': '', 'example3': '', 'example4': '', 'response': '2', 'questionid': 'G.GOVERNANCE.DPL.e.e1.BREACH'}

Later 'duplicate' (Inserted rather than updated):

{'example0': '', 'example1': '', 'example2': '', 'example3': '', 'example4': '', 'response': '', 'confidence': '', 'questionid': 'G.GOVERNANCE.DPL.e.e1.BREACH', 'privatenotes': '', 'justification': ''}

(Current mitigation: We have a management script that looks for these cases, and removes the later duplicate entries - but it has to be run manually).

Possible explanations:

  • We are not sure what is causing this to happen. Areas to investigate may be:
    • Are there times when the survey is failing to load existing answers and then triggering an update on lots of fields - or triggering update on lots of fields before answer data has been properly loaded?

Removed responses

Expected behaviour: Once set, the response to a question should only be changed by user input.

Observed behaviour: We are seeing surveys where at the same time, an update takes place which sets a large number of questions responses to blank.

Example from our debug script for this:

The older log entry (242128) for question U.COMPANY.DUEDIL.e.e2.AI from 2021-07-21 07:11:16.545850+00:00 has a response of 2 whereas the later log entry (242702) from 2021-07-21 07:58:34.186739+00:00 does not.

Replace: 
 {'id': 27804, 'data': {'example0': '', 'example1': '', 'example2': '', 'example3': '', 'example4': '', 'response': '', 'questionid': 'U.COMPANY.DUEDIL.e.e2.AI'}, 'type_id': 2, 'survey_id': 171} 

 with:
{'id': 27804, 'data': {'example0': '', 'example1': '', 'example2': '', 'example3': '', 'example4': '', 'response': '2', 'questionid': 'U.COMPANY.DUEDIL.e.e2.AI'}, 'type_id': 2, 'survey_id': 171}

What we need to do

Investigate what is causing these issues and aim to put fixes in place.

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