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

When multiple tenants exist, Drop Tenant Results in an incorrect FHIRDATA.PARAMETER_NAMES association and drop. #2354

Closed
prb112 opened this issue May 12, 2021 · 1 comment
Assignees
Labels
bug Something isn't working persistence

Comments

@prb112
Copy link
Contributor

prb112 commented May 12, 2021

Describe the bug
When multiple tenants exist, Drop Tenant Results in an incorrect FHIRDATA.PARAMETER_NAMES association and drop.

2021-05-12 12:13:59.397 00000001    INFO   com.ibm.fhir.schema.app.Main Dropping tablespace for tenant 2/test1d
2021-05-12 12:14:08.973 00000001 WARNING ls.pool.PoolConnectionProvider Rolling back transaction
2021-05-12 12:14:08.977 00000001  SEVERE   com.ibm.fhir.schema.app.Main schema tool failed

com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-282, SQLSTATE=55024, SQLERRMC=TS_TENANT2;FHIRDATA.PARAMETER_NAMES, DRIVER=4.28.11
com.ibm.fhir.database.utils.api.DataAccessException: com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-282, SQLSTATE=55024, SQLERRMC=TS_TENANT2;FHIRDATA.PARAMETER_NAMES, DRIVER=4.28.11
        at com.ibm.fhir.database.utils.db2.Db2Translator.translate(Db2Translator.java:115)
        at com.ibm.fhir.database.utils.db2.Db2DropTablespace.run(Db2DropTablespace.java:46)
        at com.ibm.fhir.database.utils.common.CommonDatabaseAdapter.runStatement(CommonDatabaseAdapter.java:459)
        at com.ibm.fhir.database.utils.db2.Db2Adapter.runStatement(Db2Adapter.java:546)
        at com.ibm.fhir.database.utils.db2.Db2Adapter.dropTablespace(Db2Adapter.java:430)
        at com.ibm.fhir.database.utils.db2.Db2Adapter.dropTenantTablespace(Db2Adapter.java:580)
        at com.ibm.fhir.database.utils.model.PhysicalDataModel.dropTenantTablespace(PhysicalDataModel.java:519)
        at com.ibm.fhir.schema.app.Main.dropDetachedPartitionTables(Main.java:1152)
        at com.ibm.fhir.schema.app.Main.dropTenant(Main.java:1106)
        at com.ibm.fhir.schema.app.Main.process(Main.java:1803)
        at com.ibm.fhir.schema.app.Main.main(Main.java:1860)
Caused by: com.ibm.db2.jcc.am.SqlException: DB2 SQL Error: SQLCODE=-282, SQLSTATE=55024, SQLERRMC=TS_TENANT2;FHIRDATA.PARAMETER_NAMES, DRIVER=4.28.11
        at com.ibm.db2.jcc.am.b7.a(b7.java:815)
        at com.ibm.db2.jcc.am.b7.a(b7.java:66)
        at com.ibm.db2.jcc.am.b7.a(b7.java:140)
        at com.ibm.db2.jcc.am.k6.c(k6.java:2825)
        at com.ibm.db2.jcc.am.k6.d(k6.java:2809)
        at com.ibm.db2.jcc.am.k6.b(k6.java:2169)
        at com.ibm.db2.jcc.t4.ab.k(ab.java:444)
        at com.ibm.db2.jcc.t4.ab.c(ab.java:102)
        at com.ibm.db2.jcc.t4.p.b(p.java:38)
        at com.ibm.db2.jcc.t4.av.h(av.java:124)
        at com.ibm.db2.jcc.am.k6.ak(k6.java:2164)
        at com.ibm.db2.jcc.am.k6.a(k6.java:3367)
        at com.ibm.db2.jcc.am.k6.c(k6.java:789)
        at com.ibm.db2.jcc.am.k6.executeUpdate(k6.java:768)
        at com.ibm.fhir.database.utils.db2.Db2DropTablespace.run(Db2DropTablespace.java:41)
        ... 9 more
2021-05-12 12:14:08.979 00000001  SEVERE   com.ibm.fhir.schema.app.Main SCHEMA CHANGE: RUNTIME ERROR

Environment
Which version of IBM FHIR Server?
main

To Reproduce
Steps to reproduce the behavior:

  1. Create a Db2 instance
mkdir -p db
docker run -itd --name mydb2_1631 --rm --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=change-password -e DBNAME=fhirdb -v $(pwd)/db:/database ibmcom/db2:11.5.4.0
  1. Configure the Db2 instance.
docker exec -it mydb2_1631 /bin/bash
su - db2inst1
/opt/ibm/db2/V11.5/bin/db2 CREATE DB FHIRDB using codeset UTF-8 territory us PAGESIZE 32768

Optionally, you may need to drop the db /opt/ibm/db2/V11.5/bin/db2 drop db fhirdb.

  1. Build Main mvn clean install -f fhir-parent -DskipTests

  2. Create Schemas

java -jar ~/.m2/repository/com/ibm/fhir/fhir-persistence-schema/4.8.0-SNAPSHOT/fhir-persistence-schema-4.8.0-SNAPSHOT-cli.jar \
    --prop db.host=localhost --prop db.port=50000 --prop db.database=fhirdb --prop user=db2inst1 --prop password=change-password \
    --db-type db2 --schema-name test1 --create-schemas
  1. Update Schema
java -jar ~/.m2/repository/com/ibm/fhir/fhir-persistence-schema/4.8.0-SNAPSHOT/fhir-persistence-schema-4.8.0-SNAPSHOT-cli.jar \
    --prop db.host=localhost --prop db.port=50000 --prop db.database=fhirdb --prop user=db2inst1 --prop password=change-password \
    --db-type db2  --update-schema
  1. Allocate Tenant1 with TEST1
java -jar ~/.m2/repository/com/ibm/fhir/fhir-persistence-schema/4.8.0-SNAPSHOT/fhir-persistence-schema-4.8.0-SNAPSHOT-cli.jar \
    --prop db.host=localhost --prop db.port=50000 --prop db.database=fhirdb --prop user=db2inst1 --prop password=change-password \
    --db-type db2   --allocate-tenant test1c
  1. Allocate Tenant2 with TEST1
java -jar ~/.m2/repository/com/ibm/fhir/fhir-persistence-schema/4.8.0-SNAPSHOT/fhir-persistence-schema-4.8.0-SNAPSHOT-cli.jar \
    --prop db.host=localhost --prop db.port=50000 --prop db.database=fhirdb --prop user=db2inst1 --prop password=change-password \
    --db-type db2 --allocate-tenant test1d
  1. Drop the second tenant test1d
java -jar ~/.m2/repository/com/ibm/fhir/fhir-persistence-schema/4.8.0-SNAPSHOT/fhir-persistence-schema-4.8.0-SNAPSHOT-cli.jar \
    --prop db.host=localhost --prop db.port=50000 --prop db.database=fhirdb --prop user=db2inst1 --prop password=change-password \
    --db-type db2  --drop-tenant test1d

You'll end up with an issue on the drop of the table space.

Expected behavior
Should succeed the drop of the tablespace.

Additional context
n/a

@prb112 prb112 added bug Something isn't working persistence labels May 12, 2021
@prb112 prb112 changed the title Drop Tenant Results in an incorrect FHIRDATA.PARAMETER_NAMES association and drop. When multiple tenants exist, Drop Tenant Results in an incorrect FHIRDATA.PARAMETER_NAMES association and drop. May 12, 2021
@prb112 prb112 self-assigned this May 12, 2021
@prb112 prb112 added this to the Sprint 2021-08 milestone Jun 1, 2021
prb112 added a commit that referenced this issue Jun 9, 2021
Cleanly handle tablespace removal error (fix for  When multiple tenants exist, Drop Tenant Results in an incorrect FHIRDATA.PARAMETER_NAMES association and drop. #2354 )
@punktilious
Copy link
Collaborator

Db2 sometimes takes a long time to perform the asynchronous table actions, so the --drop-detached command may need to be executable multiple times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working persistence
Projects
None yet
Development

No branches or pull requests

2 participants