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

Health check fails because subscriptions table no longer references collections directly #9452

Open
nwoodward opened this issue Apr 5, 2024 · 3 comments · May be fixed by #9453
Open

Health check fails because subscriptions table no longer references collections directly #9452

nwoodward opened this issue Apr 5, 2024 · 3 comments · May be fixed by #9453
Assignees
Labels
Milestone

Comments

@nwoodward
Copy link
Contributor

Describe the bug
A small bug was introduced by #8620 that we noticed while running the health check. As a result of the PR, the Subscriptions table no longer references collections directly, instead using dspace_object_id. But the findCollectionsWithSubscribers method in CollectionDAOImpl.java still references the collection field of subscriptions.

@Override
public List<Collection> findCollectionsWithSubscribers(Context context) throws SQLException {
return list(createQuery(context, "SELECT DISTINCT col FROM Subscription s join s.collection col"));
}

Stacktrace:

Exception occurred when processing report - java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: collection of: org.dspace.eperson.Subscription [SELECT DISTINCT col FROM org.dspace.eperson.Subscription s join s.collection col]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:757)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:114)
at jdk.internal.reflect.GeneratedMethodAccessor66.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.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:351)
at jdk.proxy2/jdk.proxy2.$Proxy137.createQuery(Unknown Source)
at org.dspace.core.AbstractHibernateDAO.createQuery(AbstractHibernateDAO.java:137)
at org.dspace.content.dao.impl.CollectionDAOImpl.findCollectionsWithSubscribers(CollectionDAOImpl.java:162)
at org.dspace.content.CollectionServiceImpl.findCollectionsWithSubscribers(CollectionServiceImpl.java:846)
at org.dspace.health.UserCheck.run(UserCheck.java:109)
at org.dspace.health.Check.report(Check.java:31)
at org.dspace.health.Report.run(Report.java:69)
at org.dspace.health.Report.main(Report.java:196)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.dspace.app.launcher.ScriptLauncher.runOneCommand(ScriptLauncher.java:283)
at org.dspace.app.launcher.ScriptLauncher.handleScript(ScriptLauncher.java:134)
at org.dspace.app.launcher.ScriptLauncher.main(ScriptLauncher.java:99)
Caused by: org.hibernate.QueryException: could not resolve property: collection of: org.dspace.eperson.Subscription [SELECT DISTINCT col FROM org.dspace.eperson.Subscription s join s.collection col]
at org.hibernate.QueryException.generateQueryException(QueryException.java:120)
at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:220)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:144)
at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:112)
at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:73)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:162)
at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:636)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:748)
... 20 more
Caused by: org.hibernate.QueryException: could not resolve property: collection of: org.dspace.eperson.Subscription
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:78)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:72)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:2053)
at org.hibernate.hql.internal.ast.tree.FromElementType.getPropertyType(FromElementType.java:412)
at org.hibernate.hql.internal.ast.tree.FromElement.getPropertyType(FromElement.java:524)
at org.hibernate.hql.internal.ast.tree.DotNode.getDataType(DotNode.java:723)
at org.hibernate.hql.internal.ast.tree.DotNode.prepareLhs(DotNode.java:268)
at org.hibernate.hql.internal.ast.tree.DotNode.resolve(DotNode.java:208)
at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:114)
at org.hibernate.hql.internal.ast.tree.FromReferenceNode.resolve(FromReferenceNode.java:109)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:411)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:4007)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3793)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3671)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:746)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:602)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:339)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:287)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:276)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:192)
... 26 more

To Reproduce
Steps to reproduce the behavior:

  1. Have at least one subscription to a collection in the subscriptions table
  2. Run [dspace]/bin/dspace healthcheck -e person@example.org
  3. Observe that the error occurs when it gets to the User summary section of the health check.

Expected behavior
The health check should finish without errors.

Related work
#8620

@nwoodward nwoodward added bug needs triage New issue needs triage and/or scheduling labels Apr 5, 2024
@tdonohue tdonohue added this to the 8.0 milestone Apr 5, 2024
@tdonohue tdonohue removed the needs triage New issue needs triage and/or scheduling label Apr 5, 2024
@alanorth
Copy link
Contributor

I'm trying to check this on my DSpace 7.6.1 instance but I've been waiting a few hours now and it has only reached here:

$ dspace healthcheck -e eperson@example.com

#### General Information [took: 88s] [# lines: 5]
Generated: Tue Apr 30 10:51:15 CEST 2024
From - Till: 2024-04-23 - 2024-04-30
Url: https://example.com

Assetstore size     : 140 GB
Log dir size        : 844 MB

##############################

@nwoodward
Copy link
Contributor Author

Yes, on our larger repositories the running time can be several hours. Based on the sizes of your assetstore and logs I'd guess this is your case, too. You could try running it on a smaller or test DSpace instance, or you could remove some of the longer running checks in [dspace]/config/modules/healthcheck.cfg like the Log Analyser Check.

@alanorth
Copy link
Contributor

alanorth commented May 2, 2024

Ah hah! I got the exception after thirty hours or so:

#### User summary [took: 0s] [# lines: 58]
Exception occurred when processing report - java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: collection of: org.dspace.eperson.Subscription [SELECT DISTINCT col FROM org.dspace.eperson.Subscription s join  s.collection col]

Testing the patch now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
3 participants