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

Ensure Server version generation occurs on sequential manner #366

Closed
7 of 8 tasks
githengi opened this issue Nov 16, 2020 · 1 comment · Fixed by #370
Closed
7 of 8 tasks

Ensure Server version generation occurs on sequential manner #366

githengi opened this issue Nov 16, 2020 · 1 comment · Fixed by #370
Assignees
Labels
bug Something isn't working Priority: High This is a high priority issue

Comments

@githengi
Copy link
Contributor

githengi commented Nov 16, 2020

We need to ensure that server versions assignment are sequential to ensure API clients to not miss some records.

Below is the implementation plan

  • Add a method persist on BaseRepository interface that will be called to save or update a record. It shall accept an entity and boolean new which determines if its an insert or update
  • Make the persist method synchronized so that only one thread can execute it a time
  • Generate the server version in the persist method so that the server version is generated and record saved in one atomic transaction
  • Update the service method to use persist the method
  • Remove the calls to generate server version on service methods
  • Make the method to generate server version protected/private so that they are only called from the repositories
  • Add/Update unit tests
  • Add integration tests for OpenSRP task/getAll API seems to miss concurrently-created serverVersions (reveal-stage instance) opensrp-server-web#611 (comment)
@githengi githengi transferred this issue from opensrp/opensrp-server-web Nov 23, 2020
@githengi githengi changed the title Create Server versions using a queue. Ensure Server version generation occurs on sequential manner Nov 23, 2020
@githengi githengi self-assigned this Nov 23, 2020
@githengi githengi added bug Something isn't working Priority: High This is a high priority issue labels Nov 23, 2020
@githengi
Copy link
Contributor Author

githengi commented Nov 24, 2020

The above approach will only work on single server instances. The below changes will be added to support running several OpenSRP servers

  • Add server version columns on the main database tables

  • Generate the server version during insert or update of record on main table and return on mapper

  • Update the server version on entity from the value returned on save/update

  • Update the entity with server version and execute update, use primary key for update

  • Process the metadata save as is

Update server version generation for

  • event
  • client
  • report
  • location
  • structure
  • location
  • plan
  • task
  • settings
  • view configuration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority: High This is a high priority issue
Projects
None yet
1 participant