Skip to content

Merge master into feature/py3: Fix races for CI #5738

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

Conversation

bernhardkaindl
Copy link
Collaborator

This PR merges the latest xen-api/master branch into xen-api/feature/py3 to fix race conditions in CI.

Merging these latest commits from master into feature/py3 was recommended by @psafont and @edwintorok in #5733.

FYI: @ashwin9390 and @stephenchengCloud

edwintorok and others added 5 commits June 26, 2024 09:46
The code in 'next_task_id' has a race condition:

```
(* thread 1 *)
42 = !counter (* fine, integer ref operations are atomic on OCaml 4 *)
result = string_of_int (* allocates, may process pending signals and switch to another OCaml thread! *)
(* thread 2 *)
42 = !counter
result = "42"
incr counter (* fine, this is atomic on OCaml 4 *)
result (* thread 2 got task id 42 *)
(* thread 1 *)
incr counter (* fine, this is atomic on OCaml 4 *)
result (* thread 1 got same task id as thread 2: 42! *)
```

The solution is to:
* use mutexes,
* rearrange the order of operations to avoid allocations in the critical section
* use Atomic.fetch_and_add (also makes this future proof for OCaml 5)

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
The previous unit test step has created some tasks, and deleted them when completed.
However it didn't look at events.
The next step was waiting for some newly created tasks to complete and looking at events.
But it was processing all events, even those that it wasn't watching for.
These events may have referred to tasks that were already deleted.

Fix the code to only query the state of the tasks that we are waiting for
(if these go missing, it is a bug).

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
…askbugfix

CA-394882,CA-394883: Fix task server race condition, and testcase race condition
For regular replies we look at the request and reply with a matching version.
However when we fail to parse the JsonRPC request itself then we don't know what version to use.

XenCenter uses JsonRPC v2 by default, and JsonRPC v2 has been supported in XAPI for a long time.

Signed-off-by: Edwin Török <edwin.torok@cloud.com>
…y3-for-2nd-ci-fix

Signed-off-by: Bernhard Kaindl <bernhard.kaindl@cloud.com>
@psafont psafont merged commit 91a4824 into xapi-project:feature/py3 Jun 26, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants