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

ETL fails when concept recreated with same name #92

Closed
Tracked by #93 ...
mahalakshme opened this issue Mar 14, 2024 · 6 comments
Closed
Tracked by #93 ...

ETL fails when concept recreated with same name #92

mahalakshme opened this issue Mar 14, 2024 · 6 comments
Assignees

Comments

@mahalakshme
Copy link
Contributor

mahalakshme commented Mar 14, 2024

Need:

Frequently to change datatype of a concept, the old concept is renamed or deleted. And then new concept with the right datatype is created with the same name. And when ETL runs again after the creation of the new concept, it fails with error org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [alter table {schema_name}.{table_name} add column {column_name} {new_data_type}

Issues:

  • Was able to reproduce the issue in prerelease, uninhibiteduat, concept name: Who is responsible for cleaning the toilets?
  • Try doing select * from scheduled_job_run where error_message like '%add_column%' order by id desc; - in prod everytime I do there are atleast consistent failures in 2 to 4 orgs.
  • In IPH SCD UAT on March 13, concept name 'HydroxyUrea is contra indicated in pregnancy' of Text type was voided first and concept with same name with coded type created after that. ETL failed 'stating the column already exists' and below are its logs.
  • Similarly in 'At what age formula food given' was changed from Coded to Numeric again leading to ETL failure on 19th Feb
  • 'Post Office Account no' in sakhiapp changed from Numeric to Text - same case - has been failing until February

Acceptance criteria:

  • ETL should not fail and should handle the scenario.
  • Whether the old concept was deleted or just disassociated from the form, the change in data type should reflect in the ETL table without failing.

Questions:

Aren't we first doing the necessary deletes/renames before creating?

Inputs:

rename before creating
DBT-integration test code
complex trans

ETL failure logs:

org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [alter table iphscd_uat.participant_sickle_cell_disease_affected_follow_up_scd add column "HydroxyUrea is contra indicated in pregnancy" text;] at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:99) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:79) at org.springframework.jdbc.core.JdbcTemplate.translateException(JdbcTemplate.java:1538) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:393) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:431) at org.avniproject.etl.repository.SchemaMetadataRepository.lambda$applyChanges$24(SchemaMetadataRepository.java:298) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.avniproject.etl.repository.SchemaMetadataRepository.applyChanges(SchemaMetadataRepository.java:298) at jdk.internal.reflect.GeneratedMethodAccessor63.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:702) at org.avniproject.etl.repository.SchemaMetadataRepository$$SpringCGLIB$$0.applyChanges(<generated>) at org.avniproject.etl.service.SchemaMigrationService.migrate(SchemaMigrationService.java:39) at jdk.internal.reflect.GeneratedMethodAccessor60.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343) at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:391) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184) at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:750) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:702) at org.avniproject.etl.service.SchemaMigrationService$$SpringCGLIB$$0.migrate(<generated>) at org.avniproject.etl.service.EtlService.runFor(EtlService.java:52) at org.avniproject.etl.service.EtlService.runFor(EtlService.java:35) at org.avniproject.etl.scheduler.EtlJob.execute(EtlJob.java:27) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) Caused by: org.postgresql.util.PSQLException: ERROR: column "HydroxyUrea is contra indicated in pregnancy" of relation "participant_sickle_cell_disease_affected_follow_up_scd" already exists at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2713) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2401) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:368) at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:498) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:415) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:335) at org.postgresql.jdbc.PgStatement.executeCachedSql(PgStatement.java:321) at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:297) at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:292) at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:94) at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:422) at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:381) ... 36 more
@mahalakshme mahalakshme converted this from a draft issue Mar 14, 2024
This was referenced Mar 14, 2024
@mahalakshme mahalakshme mentioned this issue Nov 4, 2024
@mahalakshme mahalakshme moved this from In Analysis to In Analysis Review in Avni Product Nov 6, 2024
@mahalakshme mahalakshme moved this from In Analysis Review to Ready in Avni Product Nov 8, 2024
@petmongrels petmongrels self-assigned this Nov 25, 2024
petmongrels added a commit that referenced this issue Dec 9, 2024
…ded state to ColumnMetadata so that in subsequent runs the voiding is not required to be done again. WIP.
petmongrels added a commit that referenced this issue Dec 9, 2024
…hema rename the column and store the state in column metadata. used uuid as the identity for a column. voided column name is decoupled between avni main db and etl schemas.
@petmongrels
Copy link
Contributor

also this commit - avniproject/avni-server@dba4225

@petmongrels petmongrels moved this from In Progress to Code Review Ready in Avni Product Dec 10, 2024
@himeshr himeshr moved this from Code Review Ready to In Code Review in Avni Product Dec 11, 2024
@himeshr himeshr moved this from In Code Review to QA Ready in Avni Product Dec 13, 2024
@dinesh2096 dinesh2096 moved this from QA Ready to In QA in Avni Product Dec 16, 2024
@dinesh2096 dinesh2096 moved this from In QA to QA Ready in Avni Product Dec 16, 2024
@dinesh2096 dinesh2096 moved this from QA Ready to In QA in Avni Product Dec 16, 2024
@dinesh2096
Copy link

After deleting the concept the ETL gets failed

Db reference :

Image

ETL table reference :

Image

@dinesh2096 dinesh2096 self-assigned this Dec 16, 2024
@dinesh2096 dinesh2096 moved this from In QA to QA Failed in Avni Product Dec 16, 2024
@petmongrels petmongrels moved this from QA Failed to In Progress in Avni Product Dec 17, 2024
@petmongrels
Copy link
Contributor

the issue is not reproducible. Currently ETL status is passed. I tried deleting one more field. The ETL passed again after that also.
Maybe the issue is with how the data is shown when the job is running the status is shown incorrectly.

@petmongrels petmongrels moved this from In Progress to QA Ready in Avni Product Dec 19, 2024
@dinesh2096 dinesh2096 moved this from QA Ready to In QA in Avni Product Dec 19, 2024
@dinesh2096
Copy link

Env: Pre-release
Org : testdashboard
user : dinesh@testdashboard

Steps to reproduce :

1.Created the Concept as named as Test ETL
2.And delete the Test ETL concept in the webapp
3.ETL sync got completed without any issue
4.But ETL Table still shows the concept without table updated to voided.

Refer the DB image :

Image

Web app image :

Image

@dinesh2096 dinesh2096 moved this from In QA to QA Failed in Avni Product Dec 20, 2024
@petmongrels petmongrels moved this from QA Failed to In Progress in Avni Product Dec 23, 2024
@petmongrels
Copy link
Contributor

ETL not deployed on prerelease.

@petmongrels petmongrels moved this from In Progress to QA Ready in Avni Product Dec 23, 2024
@dinesh2096 dinesh2096 moved this from QA Ready to In QA in Avni Product Dec 23, 2024
@dinesh2096
Copy link

  • Tested the org without changes
  • Tested by adding the concept named as Test ETL(text) and validate the ETL table.
  • Tested by deleting the same concept and validate the ETL Table
  • Tested by adding the same concept again and validate the ETL Table
  • Tested by deleting the same concept and added the with the same name but with diff concept eg: Test ETL(coded) and validate the ETL table

@dinesh2096 dinesh2096 moved this from In QA to Done in Avni Product Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants