UniTime / unitime

Comprehensive University Timetabling System
http://www.unitime.org
Apache License 2.0
283 stars 163 forks source link

Error on running solver #130

Closed denzyego closed 1 year ago

denzyego commented 1 year ago

Greetings Muller,

I trust you are well.

I am getting the error below when loading the solver, what could be the issue?

Your assistance is highly appreciated.

FATAL: Unable to load input data, reason: failed to lazily initialize a collection of role: org.unitime.timetable.model.DistributionPref.distributionObjects, could not initialize proxy - no Session <<< org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.unitime.timetable.model.DistributionPref.distributionObjects, could not initialize proxy - no Session at org.hibernate.collection.internal.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:576) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:215) at org.hibernate.collection.internal.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:156) at org.hibernate.collection.internal.PersistentSet.size(PersistentSet.java:160) at java.util.TreeSet.addAll(TreeSet.java:300) at java.util.TreeSet.(TreeSet.java:160) at org.unitime.timetable.model.DistributionPref.getOrderedSetOfDistributionObjects(DistributionPref.java:312) at org.unitime.timetable.solver.TimetableDatabaseLoader.loadGroupConstraint(TimetableDatabaseLoader.java:1910) at org.unitime.timetable.solver.TimetableDatabaseLoader.load(TimetableDatabaseLoader.java:2865) at org.unitime.timetable.solver.TimetableDatabaseLoader.load(TimetableDatabaseLoader.java:2151) at org.cpsolver.ifs.util.ProblemLoader.run(ProblemLoader.java:100) at java.lang.Thread.run(Thread.java:750)

tomas-muller commented 1 year ago

This could be caused by a distribution preference pointing to a class or a scheduling subpart that no longer exists. Does any of the following queries return any results? You can use the Administration > Utilities > Test HQL page and run the following queries (one by one):

select count(o) from DistributionObject o where o.prefGroup.uniqueId not in (select g.uniqueId from PreferenceGroup g)

select count(p) from Preference p where p.owner.uniqueId not in (select g.uniqueId from PreferenceGroup g)

Ideally, the returned count should be zero in both cases. If there is a higher count returned, you can clean them up with the following queries:

delete DistributionObject o where o.prefGroup.uniqueId not in (select g.uniqueId from PreferenceGroup g)

delete Preference p where p.owner.uniqueId not in (select g.uniqueId from PreferenceGroup g)

delete DistributionPref p where p.owner.uniqueId in (select d.uniqueId from Department d) and 0 = (select count(o) from DistributionObject o where o.distributionPref.uniqueId = p.uniqueId)

If this does not help, please check the tomcat log for some additional error messages. You could also share a database dump (e.g., created using by mysqldump) of your timetable database with me (send it to support@unitime.org) so that I can try to reproduce the issue.

denzyego commented 1 year ago

Works like a Charm!

Thank you very much for your prompt reply.

tomas-muller commented 1 year ago

You are welcome. Unfortunately, due to the polymorph relation between preferences and their owners (a preference can be set on a class, a scheduling subpart, or an instructor) or the distribution preference objects (a distribution can be set between classes and/or scheduling subparts), we cannot use foreign keys. So, it is possible that sometimes there is a record pointing to a class or a subpart that no longer exists, especially if there have been some changes done directly in the database, or some classes or subparts (that already had preferences on them) were deleted by an XML import.

denzyego commented 1 year ago

Thanks for the clarification, this actually happened after I did roll forward the previous academic session to the new one and deleted the scheduling_subparts, instr_offeringconfig & class data respectively so as to have clean data in the new academic session i.e without the previous instructional offering configurations.. : I achieved this with the following steps;

With the current session, I identified the max unique ids with the query below; select max(uniqueid) from scheduling_subpart; --615809068 select max(uniqueid) from instr_offering_config;--615776273 select max(subpartid) from class; --615809068

After rolling forward to the new session, I deleted any ids greater than the ones identified above with the query below; delete from scheduling_subpart where uniqueid >615809068 delete from instr_offeringconfig where uniqueid >615776273 delete from class where subpart_id > 615809068

I wonder if there's an easier way of doing this such that after rolling forward, I only retain the instructional offerings without the respective configurations (assigned instructors, allocated venues, configuration limit..) from the previous session.

tomas-muller commented 1 year ago

This is not a very good way, especially as it may leave other objects (like preferences or distributions) pointing to classes or subparts that have been deleted. You may be better off exporting courses, adjusting the XML file to remove items you do not want, and reimporting it into the next academic session (or creating an XML of courses based on your SIS/course catalog with only the information needed). Alternatively, please take a look at the attached script (to be imported using the Data Exchange page, after which it appears on the Scripts page), which makes all offered courses not offered.

Make Not Offered (all offered courses).xml.gz