500: Unexpected server error when trying to delete folder.

General Server Forum (Inactive)
500: Unexpected server error when trying to delete folder. hwong  2017-10-16 15:08
Status: Closed
 
I am trying to delete some folders in Labkey but I get this error:

500: Unexpected server error

SqlExecutor.execute(); SQL []; ERROR: update or delete on table "material" violates foreign key constraint "fk_materialinput_material" on table "materialinput" Detail: Key (rowid)=(1522) is still referenced from table "materialinput".; nested exception is org.postgresql.util.PSQLException: ERROR: update or delete on table "material" violates foreign key constraint "fk_materialinput_material" on table "materialinput" Detail: Key (rowid)=(1522) is still referenced from table "materialinput".

org.springframework.dao.DataIntegrityViolationException: SqlExecutor.execute(); SQL []; ERROR: update or delete on table "material" violates foreign key constraint "fk_materialinput_material" on table "materialinput"
  Detail: Key (rowid)=(1522) is still referenced from table "materialinput".; nested exception is org.postgresql.util.PSQLException: ERROR: update or delete on table "material" violates foreign key constraint "fk_materialinput_material" on table "materialinput"
  Detail: Key (rowid)=(1522) is still referenced from table "materialinput".
       at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:243)
       at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
       at org.labkey.api.data.ExceptionFramework$1.translate(ExceptionFramework.java:37)
       at org.labkey.api.data.ExceptionFramework$1.translate(ExceptionFramework.java:31)
       at org.labkey.api.data.SqlExecutor.execute(SqlExecutor.java:129)
       at org.labkey.api.data.SqlExecutor.execute(SqlExecutor.java:75)
       at org.labkey.api.data.SqlExecutor.execute(SqlExecutor.java:70)
       at org.labkey.api.data.Table.delete(Table.java:992)
       at org.labkey.study.SpecimenManager.deleteAllSampleData(SpecimenManager.java:2059)
       at org.labkey.study.model.StudyManager.deleteAllStudyData(StudyManager.java:3042)
       at org.labkey.study.StudyContainerListener.containerDeleted(StudyContainerListener.java:48)
       at org.labkey.api.data.ContainerManager.fireDeleteContainer(ContainerManager.java:1965)
       at org.labkey.api.data.ContainerManager.delete(ContainerManager.java:1437)
       at org.labkey.api.data.ContainerManager.deleteAll(ContainerManager.java:1500)
       at org.labkey.core.admin.AdminController$DeleteFolderAction.handlePost(AdminController.java:5008)
       at org.labkey.core.admin.AdminController$DeleteFolderAction.handlePost(AdminController.java:4974)
       at org.labkey.api.action.FormViewAction.handleRequest(FormViewAction.java:101)
       at org.labkey.api.action.FormViewAction.handleRequest(FormViewAction.java:80)
       at org.labkey.api.action.BaseViewAction.handleRequest(BaseViewAction.java:177)
       at org.labkey.api.action.SpringActionController.handleRequest(SpringActionController.java:416)
       at org.labkey.api.module.DefaultModule.dispatch(DefaultModule.java:1226)
       at org.labkey.api.view.ViewServlet._service(ViewServlet.java:205)
       at org.labkey.api.view.ViewServlet.service(ViewServlet.java:132)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
       at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
       at org.labkey.api.data.TransactionFilter.doFilter(TransactionFilter.java:38)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
       at org.labkey.core.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:118)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
       at org.labkey.api.module.ModuleLoader.doFilter(ModuleLoader.java:1147)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
       at org.labkey.api.security.AuthFilter.doFilter(AuthFilter.java:217)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
       at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
       at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
       at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
       at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
       at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2517)
       at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2506)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
       at java.lang.Thread.run(Thread.java:745)
Caused by: org.postgresql.util.PSQLException: ERROR: update or delete on table "material" violates foreign key constraint "fk_materialinput_material" on table "materialinput"
  Detail: Key (rowid)=(1522) is still referenced from table "materialinput".
       at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2412)
       at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2125)
       at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:297)
       at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:428)
       at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:354)
       at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:169)
       at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:158)
       at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
       at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
       at org.labkey.api.data.dialect.StatementWrapper.execute(StatementWrapper.java:1506)
       at org.labkey.api.data.SqlExecutor$NormalStatementExecutor.execute(SqlExecutor.java:168)
       at org.labkey.api.data.SqlExecutor$NormalStatementExecutor.execute(SqlExecutor.java:144)
       at org.labkey.api.data.SqlExecutor.execute(SqlExecutor.java:122)
       ... 52 more
DialectSQL = DELETE FROM exp.material
        WHERE (container = '04067a76-8919-1035-8de5-eff8467388c4')

request attributes
LABKEY.OriginalURL = http://labkey/POG/admin-deleteFolder.view?recurse=1
LABKEY.StartTime = 1508191468659
LABKEY.action = deleteFolder
org.springframework.web.servlet.DispatcherServlet.CONTEXT = Root WebApplicationContext: startup date [Wed Aug 30 15:12:02 PDT 2017]; parent: Root WebApplicationContext
LABKEY.controller = admin
LABKEY.Counter = 0
X-LABKEY-CSRF = 9397d4bd9745b637714fbf852cced417
LABKEY.container = /POG
LABKEY.RequestURL = /POG/admin-deleteFolder.view?recurse=1
LABKEY.OriginalURLHelper = /POG/admin-deleteFolder.view?recurse=1

core schema database configuration
Server URL    jdbc:postgresql://localhost:5432/labkey
Product Name    PostgreSQL
Product Version    9.5.3
Driver Name    PostgreSQL JDBC Driver
Driver Version    42.0.0
 
 
Jon (LabKey DevOps) responded:  2017-10-16 21:38
Hello,

It looks like you have either assays and/or sample sets within that same container that you're deleting.

I believe we had fixed this in the most recent version of LabKey 17.2 and this is also fixed in LabKey 17.3 which will be out in a few weeks.

https://www.labkey.org/home/Developer/issues/issues-details.view?issueId=28137

What version of LabKey are you running?

As a workaround, have you tried to delete the assays within the folder first before trying to delete the entire folder?

Regards,

Jon
 
Mya Warren responded:  2017-10-17 09:18
Hi Jon,
I'm working with Hansen. I think I've fixed the problem. For the record, this is what I had to do:
- Remove each assay design from the assay list one at a time
- Delete the assay files (can't delete files until the assay has been deleted)
- Delete the study directory
 
hwong responded:  2017-10-17 10:27
We have Labkey17.2-52553 installed. I'm basing this off the setup executable that I have. Is there another way to verify the version we are running?
 
Jon (LabKey DevOps) responded:  2017-10-17 21:37
Yes, if you go into the Admin Console and expand the module section for Core, you should see the revision number of LabKey (that 5 digit number).
 
hwong responded:  2017-10-18 12:21
Looks like 17.2, but I'm not sure which number is the revision number so I'll paste what I think might be relevant.

Build Number    52553.21
Build OS    Windows Server 2012 R2
Build Path    Z:\teamcity\work\d503835eb40d8d2f\build\modules\core
Build Time    Jul 29, 2017 1:35:23 AM
Build Type    Production
Build User    WIN-GJVER9ENROM$
Extracted Path    C:\Program Files (x86)\LabKey Server\modules\core-17.2
Module Class    org.labkey.core.CoreModule
Module Dependencies    <none>
VCS Revision    52417
VCS URL    https://hedgehog.fhcrc.org/tor/stedi/branches/release17.2/server/modules/core
Version    17.20
 
Jon (LabKey DevOps) responded:  2017-10-18 20:44
Hello,

The Build Number is the revision number. So it looks like you're running on a version of 17.2 that doesn't have that included fix. The version of 17.2 that has it must be at least r53240 or higher.

You have a few possible options:

1. Delete the assay data within the folders before deleting the folder itself.

2. Wait to upgrade to LabKey 17.3 that will be available in mid-November.

3. Upgrade to a newer version of LabKey 17.2 that has the fix.

The first option is probably the easiest one to do and doesn't take down your server in the process for upgrading purposes.

The second one is going to be available very soon and has more than just this one fix, but multiple improvements and features as well, including our new UI.

If you are however desiring to upgrade your version of 17.2 to a later version, please let us know and we will supply you with the download link information.

Regards,

Jon
 
hwong responded:  2017-10-19 13:37
Thanks. From my other thread, https://www.labkey.org/home/Support/Server%20Forum/announcements-thread.view?rowId=15978, installing Ben's LDK module updated LK to Build 54421 which has resolved this issue.