# Bug in the relaunch\_group method

**URL:** <https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29>\
**Category:** Bugs and Error Reporting\
**Created:** [May 3, 2023, 1:06pm UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29 "2023-05-03T13:06:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![tterraz](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@tterraz](https://melissa.discourse.group/u/tterraz)\
**Post date:** [May 3, 2023, 1:06pm UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/1 "2023-05-03T13:06:51Z")

</div>

Hello,

there is a bug in the relaunch\_group method of the BaseServer (see [base\_server.py](https://gitlab.inria.fr/melissa/melissa/-/blob/develop/melissa/server/base_server.py#L339)) :

```auto
self.groups[group_id].simulations[sim_id].parameters,

```

should be

```auto
self.groups[group_id].simulations[group_id * self.group_size + sim_id].parameters,

```

Sincerely,

Théophile Terraz

---

<div class="post-metadata">

**Author:** ![mschoule](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mschoule](https://melissa.discourse.group/u/mschoule)\
**Post date:** [May 3, 2023, 2:00pm UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/2 "2023-05-03T14:00:45Z")

</div>

Hi Théophile,

That’s exact, thank you very much.  
[MR 116!](https://gitlab.inria.fr/melissa/melissa/-/merge_requests/116) has been created to fix this.

---

<div class="post-metadata">

**Author:** ![tterraz](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@tterraz](https://melissa.discourse.group/u/tterraz)\
**Post date:** [May 11, 2023, 3:34pm UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/3 "2023-05-11T15:34:02Z")

</div>

Hello,

there is one more bug in the relaunch\_group method of the BaseServer (see [base\_server.py](https://gitlab.inria.fr/melissa/melissa/-/blob/develop/melissa/server/base_server.py#L347)) :

```auto
del self.groups[group_id]

```

This line should not exist. It removes the group\_idth item from the groups list, shifts all the end of the list by -1 and screw up the study. Without it, the relaunch system works well.

Sincerely,

Théophile Terraz

---

<div class="post-metadata">

**Author:** ![mschoule](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mschoule](https://melissa.discourse.group/u/mschoule)\
**Post date:** [May 12, 2023, 7:45am UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/4 "2023-05-12T07:45:03Z")

</div>

Hi Théophile,

Thank you for your input.

I am a bit confused on how this command breaks the study, could you please elaborate a bit further on the context in which you encountered an issue?

For the record, this deletion was introduced to make sure that if a group is relaunched from scratch (i.e. with new inputs), its associated simulations are re-instantiated with new `Simulation` objects (this ensures `received_simulation_data` and `received_time_steps` are empty dictionaries again for instance).

In addition, as you probably noticed, `groups` is a dictionary. Therefore, although removing the `group_id` entry will effectively shift the dictionary entries order, the keys are preserved. Since the deletion you are referring to is followed by this:

```py
for sim in range(self.group_size):
    self.generate_client_scripts(
        group_id * self.group_size + sim, 1, None
    )

```

the `group_id` key will immediately be re-introduced amongst the dictionary entries. I hence don’t understand how the change in keys order can become a problem.

Are you sure that’s where the bug lies?

---

<div class="post-metadata">

**Author:** ![tterraz](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@tterraz](https://melissa.discourse.group/u/tterraz)\
**Post date:** [May 12, 2023, 8:33am UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/5 "2023-05-12T08:33:28Z")

</div>

Hello,

I had a kind of deadlock that does not exist anymore without this line: the server was running until the walltime without error but without results. I thougt groups was a list so I came up with that explanation, but in fact I did not investigate further. But you are right, with my solution we keep the first timesteps of the failed simulations as “recieved”.

---

<div class="post-metadata">

**Author:** ![mschoule](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mschoule](https://melissa.discourse.group/u/mschoule)\
**Post date:** [May 12, 2023, 9:18am UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/6 "2023-05-12T09:18:59Z")

</div>

As you know it is very cumbersome to thoroughly test fault-tolerance features so thank you very much for your feedback.

If there is a chance of running into a deadlock situation, that’s concerning…

I do not know the degree of complexity of your working environment but if there is an easy way for us to reproduce this bug, feel free to let us know so that we can investigate it in more details.

Regards,  
Marc

---

<div class="post-metadata">

**Author:** ![tterraz](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@tterraz](https://melissa.discourse.group/u/tterraz)\
**Post date:** [June 2, 2023, 1:32pm UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/7 "2023-06-02T13:32:05Z")

</div>

Hello,

I found the deadlock and why commenting the “del” solved it:  
If you delete the group, then you will enter in [this 'if" section](https://gitlab.inria.fr/melissa/melissa/-/blob/develop/melissa/server/sensitivity_analysis/sensitivity_analysis_server.py#L159) ans then increment “self.n\_submitted\_simulations”.  
Then, you will never enter [this “if” section](https://gitlab.inria.fr/melissa/melissa/-/blob/develop/melissa/server/base_server.py#L504), causing the server to wait indefinitely.  
One dirty fix is to add:

```auto
self.n_submitted_simulations -= 1

```

before the call to “self.generate\_client\_scripts” in [“relaunch\_group.py”](https://gitlab.inria.fr/melissa/melissa/-/blob/develop/melissa/server/base_server.py#L349).

Sincerely,

Théophile Terraz

---

<div class="post-metadata">

**Author:** ![mschoule](https://avatars.discourse-cdn.com/v4/letter/m/35a633/32.png) [@mschoule](https://melissa.discourse.group/u/mschoule)\
**Post date:** [June 5, 2023, 7:14am UTC](https://melissa.discourse.group/t/bug-in-the-relaunch-group-method/29/8 "2023-06-05T07:14:19Z")

</div>

Very good catch! We’ll fix this ASAP, thank you very much 😀

**edit** : [MR !126](https://gitlab.inria.fr/melissa/melissa/-/merge_requests/126) was created to fix this.
