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

Allow fhir-bucket to bootstrap FHIRBUCKET schema #2997

Closed
punktilious opened this issue Nov 16, 2021 · 3 comments
Closed

Allow fhir-bucket to bootstrap FHIRBUCKET schema #2997

punktilious opened this issue Nov 16, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@punktilious
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Currently the FHIRBUCKET schema is deployed using a separate invocation of the fhir-bucket CLI. This was designed to make it easy to run once. It's currently not possible to "create the schema if needed" as part of a normal fhir-bucket run. Doing so would simplify deployment configuration.

Describe the solution you'd like
Allow the FHIRBUCKET schema to be created if needed (bootstrapped) when the fhir-bucket CLI starts. Use the CONTROL table lease mechanism developed for the main FHIRDATA schema to ensure that the schema processing is serialized if multiple instances of fhir-bucket are started at the same time.

Describe alternatives you've considered
Use (complex) deployment configurations to achieve the same behavior.

Acceptance Criteria

  1. GIVEN an empty database
    WHEN fhir-bucket is run
    AND the bootstrap-schema option is provided
    THEN the schema will be deployed before the main fhir-bucket processing starts

  2. GIVEN a deployed fhir-bucket schema
    WHEN fhir-bucket is run
    AND the bootstrap-schema option is provided
    THEN the schema updates will be applied before the main fhir-bucket processing starts

  3. GIVEN a deployed fhir-bucket schema
    AND another instance of the fhir-bucket is started at the same time
    WHEN fhir-bucket is run
    AND the bootstrap-schema option is provided
    THEN one instance will wait for the other instance to complete its schema processing before starting

Additional context
Consider also using the WHOLE_SCHEMA_VERSION which allows the schema processing to be skipped entirely if it is at the latest version - although the fhir-bucket schema is very small, so the benefit is small.

@prb112 prb112 added the enhancement New feature or request label Nov 16, 2021
@punktilious
Copy link
Collaborator Author

Adding this now because it's convenient to do while implementing #2935 adding support to read from local directory without need for a database.

@punktilious
Copy link
Collaborator Author

This required moving the schema lease manager and whole-schema-version code to fhir-database-utils, and a corresponding change to the API to use ints for the schema version instead of FhirSchemaVersion, making it more generic. FhirSchemaVersion is now used in fhir-persistence-schema, and a new enum FhirBucketSchemaVersion is used in the fhir-bucket project, which is a nice separation.

@d0roppe
Copy link
Collaborator

d0roppe commented Jan 10, 2022

using the --bootstrap-schema option auto creates the fhirbucket schema if it is not there. also if the db is there it is update or skipped as needed.
INFO: The schema 'FHIRBUCKET' is created or already exists
Jan 10, 2022 12:40:48 PM com.ibm.fhir.database.utils.schema.LeaseManager waitForLease
INFO: Requesting update lease for schema 'FHIRBUCKET' [attempt 1]
Jan 10, 2022 12:40:48 PM com.ibm.fhir.bucket.app.Main bootstrapDb
INFO: Already at latest version; skipping update for: 'FHIRBUCKET'
Jan 10, 2022 12:40:48 PM com.ibm.fhir.database.utils.schema.LeaseManager cancelLease
INFO: Canceling lease for schema 'FHIRBUCKET'

@d0roppe d0roppe closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants