Open mokun opened 8 months ago
Let's not make any changes for this yet. It needs some careful thought. This is only a problem when the 2 Settlement trading are assigned to different Threads. I have some ideas what we can do but want to close down all the other changes we are doing first.
This is only a problem when the 2 Settlement trading are assigned to different Threads.
Ok later.
Do you think some of these concurrency issues may have to with GenericContainer extending Equipment ?
What if we free GenericContainer from being an Equipment once and for all ?!
In doing so, what will be impacted and what changes do we have to make ?
I have the following again:
01-Adir-12:204.577 (Info) DeliveryMeta [x2] : [Schiaparelli Point] Drone 019 - Available for delivery mission.
01-Adir-12:204.577 (Severe) PersonTaskManager : [Schiaparelli Point] Ruby Cook - Trouble calling performTask():
java.util.ConcurrentModificationException
at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1694)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
at java.base/java.util.stream.ReduceOps$5.evaluateSequential(ReduceOps.java:258)
at java.base/java.util.stream.ReduceOps$5.evaluateSequential(ReduceOps.java:248)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.count(ReferencePipeline.java:709)
at com.mars_sim.core.equipment.EquipmentInventory.findNumEmptyContainersOfType(EquipmentInventory.java:499)
at com.mars_sim.core.structure.Settlement.findNumEmptyContainersOfType(Settlement.java:3716)
at com.mars_sim.core.goods.CommerceUtil.getAvailableContainerForResource(CommerceUtil.java:426)
at com.mars_sim.core.goods.CommerceUtil.determineLoad(CommerceUtil.java:287)
at com.mars_sim.core.goods.CommerceUtil.getDesiredBuyLoad(CommerceUtil.java:216)
at com.mars_sim.core.goods.CommerceUtil.getPotentialDeal(CommerceUtil.java:114)
at com.mars_sim.core.goods.CommerceUtil.getBestDeal(CommerceUtil.java:73)
at com.mars_sim.core.goods.GoodsManager.getBestDeal(GoodsManager.java:768)
at com.mars_sim.core.person.ai.mission.meta.DeliveryMeta.getSettlementProbability(DeliveryMeta.java:105)
at com.mars_sim.core.person.ai.mission.meta.DeliveryMeta.getProbability(DeliveryMeta.java:69)
at com.mars_sim.core.person.ai.mission.MissionManager.getNewMission(MissionManager.java:244)
at com.mars_sim.core.person.ai.Mind.getNewMission(Mind.java:450)
at com.mars_sim.core.person.ai.task.PlanMission.selectingPhase(PlanMission.java:137)
at com.mars_sim.core.person.ai.task.PlanMission.performMappedPhase(PlanMission.java:114)
at com.mars_sim.core.person.ai.task.util.Task.executeMappedPhase(Task.java:688)
at com.mars_sim.core.person.ai.task.util.Task.performTask(Task.java:643)
at com.mars_sim.core.person.ai.task.util.PersonTaskManager.executeTask(PersonTaskManager.java:99)
at com.mars_sim.core.person.ai.Mind.takeAction(Mind.java:203)
at com.mars_sim.core.person.ai.Mind.decideTask(Mind.java:175)
at com.mars_sim.core.person.ai.Mind.timePassing(Mind.java:118)
at com.mars_sim.core.person.Person.timePassing(Person.java:859)
at com.mars_sim.core.structure.Settlement.timePassingCitizens(Settlement.java:1232)
at com.mars_sim.core.structure.Settlement.timePassing(Settlement.java:1006)
at com.mars_sim.core.UnitManager$SettlementTask.call(UnitManager.java:900)
at com.mars_sim.core.UnitManager$SettlementTask.call(UnitManager.java:1)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
01-Adir-12:204.577 (Info) CommerceUtil : [Schiaparelli Point] New best deal for a delivery mission to Heritage: Profit -1539.7.
Did you have a Trade or ďelivery operation going? I have an idea on this. We create a temporary ResourceHolder when unloading/loading at a remote Settlement and use this as a transition object. We can create and load it in one Thread and pass it to the other Thread in the other Thread. Needs some thought but would work. Would add a single pulse delay the deliver reloading task
It's too late to go back to see if there's a delivery or trade going on that it accessing this thread that is running DeliveryMeta. I've exited the sim.
Same problem as #1118
We create a temporary ResourceHolder when unloading/loading at a remote Settlement and use this as a transition object. We can create and load it in one Thread and pass it to the other Thread in the other Thread. Needs some thought but would work.
So for it to work, where will this transition object be located at what thread ?
Let's say we have 2 settlements, S1 and S2. S1 runs on the thread T1. S2 on T2.
A few settlers from S1 travelled to S2 on a trading mission.
Does this transition object reside on S2 ? or on a new temporary thread T3 that you will create ?
The correct solution to thus and #1118 is to transfer control of the Units to the visiting Settlement when they arrive there. Then when Units interact they are still in the same Thread. This removes the need to specialise every interaction because the golden rule of Units being in the same Thread is maintained. This is a job for 3.9.0
Describe the bug
TradeMeta
andDeliveryMeta
,(CommerceUtil
is used to find available containersEquipmentInventory::findNumEmptyContainersOfType
is evoked to find empty containers.containerSet
is being accessed elsewhere.Expected and unexpected behavior
containerSet
is NOT being accessed elsewhere concurrently.Java classes involved
EquipmentInventory
Stacktrace
Specifications (please complete the following information)
Additional context