gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

[GS] Cannot reload a simulation in server mode (no gui) #3922

Closed lesquoyb closed 10 months ago

lesquoyb commented 1 year ago

Describe the bug In gama-server, it is not possible anymore to control a simulation that has been reloaded, because the experiment id seem to have changed with the reload and there's no indication of what is the new experiment id. Before the recent changes in server we would use the same experiment id as the initial simulation to control the reloaded one.

To Reproduce Steps to reproduce the behavior:

  1. run a client that will load a simulation, reload it (using the experiment id) then try to interact with it (still with same experiment id)
  2. see that the return message is something like "wrong experiment id"

Expected behavior Either we can use the old experiment id as previously, or the new one is sent as a return to the reload command

Additional context This happens on server only mode (no GUI). Additionally it may be caused by an internal error, the reload command send a CommandExecutedSuccessfully message, but I noticed errors in the eclipse console:


java.lang.NullPointerException: Cannot invoke "msi.gaml.variables.IVariable.getName()" because "v" is null
    at msi.gama.metamodel.population.GamaPopulation.<init>(GamaPopulation.java:281)
    at msi.gama.kernel.experiment.ExperimentPlan$ExperimentPopulation.<init>(ExperimentPlan.java:396)
    at msi.gama.kernel.experiment.ExperimentPlan.createAgent(ExperimentPlan.java:564)
    at msi.gama.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:710)
    at msi.gama.headless.core.Experiment.loadCurrentExperiment(Experiment.java:107)
    at msi.gama.headless.core.Experiment.setup(Experiment.java:89)
    at msi.gama.headless.server.GamaServerExperimentJob.loadAndBuildWithJson(GamaServerExperimentJob.java:135)
    at msi.gama.headless.server.GamaServerExperimentController.processUserCommand(GamaServerExperimentController.java:268)
    at msi.gama.headless.server.GamaServerExperimentController.userReload(GamaServerExperimentController.java:331)
    at msi.gama.headless.listener.ReloadCommand.execute(ReloadCommand.java:58)
    at msi.gama.headless.listener.ReloadCommand.execute(ReloadCommand.java:1)
    at msi.gama.runtime.server.CommandExecutor.lambda$1(CommandExecutor.java:120)
    at java.base/java.lang.Thread.run(Thread.java:842)
java.lang.NullPointerException: Cannot invoke "msi.gaml.variables.IVariable.getName()" because "v" is null
    at msi.gama.metamodel.population.GamaPopulation.<init>(GamaPopulation.java:281)
    at msi.gama.kernel.experiment.ExperimentPlan$ExperimentPopulation.<init>(ExperimentPlan.java:396)
    at msi.gama.kernel.experiment.ExperimentPlan.createAgent(ExperimentPlan.java:564)
    at msi.gama.kernel.experiment.ExperimentPlan.open(ExperimentPlan.java:710)
    at msi.gama.headless.core.Experiment.loadCurrentExperiment(Experiment.java:107)
    at msi.gama.headless.core.Experiment.setup(Experiment.java:89)
    at msi.gama.headless.server.GamaServerExperimentJob.loadAndBuildWithJson(GamaServerExperimentJob.java:135)
    at msi.gama.headless.server.GamaServerExperimentController.processUserCommand(GamaServerExperimentController.java:268)
    at msi.gama.headless.server.GamaServerExperimentController.userReload(GamaServerExperimentController.java:331)
    at msi.gama.headless.listener.ReloadCommand.execute(ReloadCommand.java:58)
    at msi.gama.headless.listener.ReloadCommand.execute(ReloadCommand.java:1)
    at msi.gama.runtime.server.CommandExecutor.lambda$1(CommandExecutor.java:120)
    at java.base/java.lang.Thread.run(Thread.java:842)

the model I use for example is only an experiment so I don't think it is at fault here:

model reloading

experiment exp type: gui until:cycle >1
{

    list<int> closed_roads;

    output
    {
        display "display"
        {
            chart "log"
            {
                data "log" value: log(cycle+1);
            }
        }

    }
}

Update: In GUI, provided we pause long enough between load and reload to avoid exceptions, it works, but the experiment_id is actually the experiment name instead of a number as it used to be. So the problem may come from a mismatch between those two systems

lesquoyb commented 10 months ago

After some investigation I found the part that is probably at fault: following the stack trace for the NullPointerException in the first message, in the creation of the experiment's population, in GamaPopulation.java line 280, the function orderAttributes returns a list composed only of null values, though the code in that function is close to black magic to me so I really don't understand what's going on or what should be happening. @AlexisDrogoul, @hqnghi88 any pointers ?

hqnghi88 commented 10 months ago

Can you try this in GamaServerExperimentController, line 165

image
lesquoyb commented 10 months ago

Seems to work perfectly, I'll push that fix

hqnghi88 commented 10 months ago

OK, all the thing there is just to take into account the new value of parameters, which are restructured to already done before here:

image
lesquoyb commented 10 months ago

I didn't see any problem after some times using it, so closing the issue