Bug 1620198

Summary: update or delete on table "gluster_volumes" violates foreign key constraint "fk_storage_connection_to_glustervolume" on table "storage_server_connections
Product: [oVirt] ovirt-engine Reporter: Petr Kubica <pkubica>
Component: BLL.GlusterAssignee: Kaustav Majumder <kmajumde>
Status: CLOSED CURRENTRELEASE QA Contact: SATHEESARAN <sasundar>
Severity: high Docs Contact:
Priority: medium    
Version: 4.2.6.2CC: briwils2, bugs, fdelorey, godas, kmajumde, pcuzner, tnisan
Target Milestone: ovirt-4.3.2Flags: rule-engine: ovirt-4.3+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-04-16 13:56:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Gluster RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1183307, 1596034    
Attachments:
Description Flags
engine.log none

Description Petr Kubica 2018-08-22 16:19:33 UTC
Created attachment 1477930 [details]
engine.log

Description of problem:
I wanted to delete a gluster volume from webadmin, volume was deleted on gluster storage but I still see in webadmin that volume. Volume was used as data domain which was in maintenance mode.

in engine log I found:
2018-08-22 18:01:41,066+02 ERROR [org.ovirt.engine.core.bll.gluster.GlusterSyncJob] (DefaultQuartzScheduler7) [2e96c242] Error while removing volumes from database!: org.springframework.dao.DataIntegrityViolationException: CallableStatementCallback; SQL [{call deleteglustervolumesbyguids(?)}]; ERROR: update or delete on table "gluster_volumes" violates foreign key constraint "fk_storage_connection_to_glustervolume" on table "storage_server_connections"
  Detail: Key (id)=(34b2219e-b200-435d-8df6-63b2ff06df57) is still referenced from table "storage_server_connections".
  Where: SQL statement "DELETE
    FROM gluster_volumes
    WHERE id IN (
            SELECT *
            FROM fnSplitterUuid(v_volume_ids)
            )"
PL/pgSQL function deleteglustervolumesbyguids(character varying) line 3 at SQL statement; nested exception is org.postgresql.util.PSQLException: ERROR: update or delete on table "gluster_volumes" violates foreign key constraint "fk_storage_connection_to_glustervolume" on table "storage_server_connections"
  Detail: Key (id)=(34b2219e-b200-435d-8df6-63b2ff06df57) is still referenced from table "storage_server_connections".
  Where: SQL statement "DELETE
    FROM gluster_volumes
    WHERE id IN (
            SELECT *
            FROM fnSplitterUuid(v_volume_ids)
            )"
PL/pgSQL function deleteglustervolumesbyguids(character varying) line 3 at SQL statement
	at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:243) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1099) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:1135) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.core.simple.AbstractJdbcCall.executeCallInternal(AbstractJdbcCall.java:405) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.core.simple.AbstractJdbcCall.doExecute(AbstractJdbcCall.java:365) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.core.simple.SimpleJdbcCall.execute(SimpleJdbcCall.java:198) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeImpl(SimpleJdbcCallsHandler.java:135) [dal.jar:]
	at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeImpl(SimpleJdbcCallsHandler.java:130) [dal.jar:]
	at org.ovirt.engine.core.dal.dbbroker.SimpleJdbcCallsHandler.executeModification(SimpleJdbcCallsHandler.java:76) [dal.jar:]
	at org.ovirt.engine.core.dao.gluster.GlusterVolumeDaoImpl.removeAll(GlusterVolumeDaoImpl.java:236) [dal.jar:]
	at org.ovirt.engine.core.bll.gluster.GlusterSyncJob.removeDeletedVolumes(GlusterSyncJob.java:520) [bll.jar:]
	at org.ovirt.engine.core.bll.gluster.GlusterSyncJob.refreshVolumeData(GlusterSyncJob.java:464) [bll.jar:]
	at org.ovirt.engine.core.bll.gluster.GlusterSyncJob.refreshClusterData(GlusterSyncJob.java:142) [bll.jar:]
	at org.ovirt.engine.core.bll.gluster.GlusterSyncJob.refreshLightWeightData(GlusterSyncJob.java:120) [bll.jar:]
	at sun.reflect.GeneratedMethodAccessor97.invoke(Unknown Source) [:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) [rt.jar:1.8.0_181]
	at org.ovirt.engine.core.utils.timer.JobWrapper.invokeMethod(JobWrapper.java:83) [scheduler.jar:]
	at org.ovirt.engine.core.utils.timer.JobWrapper.execute(JobWrapper.java:55) [scheduler.jar:]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:213) [quartz.jar:]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0_181]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0_181]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [rt.jar:1.8.0_181]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [rt.jar:1.8.0_181]
	at java.lang.Thread.run(Thread.java:748) [rt.jar:1.8.0_181]
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "gluster_volumes" violates foreign key constraint "fk_storage_connection_to_glustervolume" on table "storage_server_connections"
  Detail: Key (id)=(34b2219e-b200-435d-8df6-63b2ff06df57) is still referenced from table "storage_server_connections".
  Where: SQL statement "DELETE
    FROM gluster_volumes
    WHERE id IN (
            SELECT *
            FROM fnSplitterUuid(v_volume_ids)
            )"
PL/pgSQL function deleteglustervolumesbyguids(character varying) line 3 at SQL statement
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:410)
	at org.jboss.jca.adapters.jdbc.CachedPreparedStatement.execute(CachedPreparedStatement.java:303)
	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.execute(WrappedPreparedStatement.java:442)
	at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1138) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate$6.doInCallableStatement(JdbcTemplate.java:1135) [spring-jdbc.jar:4.3.9.RELEASE]
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:1083) [spring-jdbc.jar:4.3.9.RELEASE]
	... 23 more


Version-Release number of selected component (if applicable):
ovirt-engine-4.2.6.4-0.0.master.20180817095858.git52c4ae5.el7.noarch

How reproducible:
always

Steps to Reproduce:
1 Create a gluster volume
2. Add that volume as data domain for virtualization
(3. put that data domain into maintenance)
4. put gluster volume into maintenance 
5. Delete that volume

Actual results:
Failed, volume is deleted but it still in webadmin as inactive
Repeatedly printed exception into engine.log
note: after removing data domain, the gluster volume was deleted also

Expected results:
should notify admin that this volume is used as data domain and provide a dialog  to approve removing also data domain

Additional info:
attached engine.log

Comment 1 Gobinda Das 2018-12-10 07:15:28 UTC
*** Bug 1182774 has been marked as a duplicate of this bug. ***

Comment 2 Gobinda Das 2019-01-03 12:44:16 UTC
Moving to 4.3.0 as it's not a blocker

Comment 3 Sandro Bonazzola 2019-01-28 09:34:43 UTC
This bug has not been marked as blocker for oVirt 4.3.0.
Since we are releasing it tomorrow, January 29th, this bug has been re-targeted to 4.3.1.

Comment 4 Sandro Bonazzola 2019-03-22 10:56:40 UTC
Moving to ON_QA being referenced patch 4fb07134e0028f23ce98a39c23bb0f4d80688fe8 already in since ovirt-engine-4.3.0_rc

Comment 7 SATHEESARAN 2019-04-11 08:55:06 UTC
Tested with RHV 4.3.3

When trying to remove the volume, and there exists the storage domain that
uses this gluster volume, then that delete volume operation is not allowed.

And user won't run in to the problems.
But still there are 2 problems,

1. Trying to stop the volume should catch this problem, instead of volume delete
So, if the gluster volume that is backing up the storage domain, is stopped, 
then that operation should be disallowed.

2. If the storage domains are auto-created as part of HC deployment, then
this check won't have effect, as there is another issue where this SD
doesn't have associated gluster volume UUID, when created automatically
from HC deployment via cockpit

I will be raising separate bugs for the same

With the above facts, verifying this bug

Comment 8 Sandro Bonazzola 2019-04-16 13:56:28 UTC
This bugzilla is included in oVirt 4.3.2 release, published on March 19th 2019.

Since the problem described in this bug report should be
resolved in oVirt 4.3.2 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.