DiamondLightSource / DiamondLightSource/epicsdbbuilder

Multithreaded access error when validating fields

Open
#32 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
9
Forks
7
PR merge metrics
No merged PRs in 30d

Description

It seems that part(s) of epicsdbbuilder are not threadsafe. Inside of [ValidateDbField](https://github.com/DiamondLightSource/epicsdbbuilder/blob/88ac2802a17b47553bc6591ec56d8b1197645b1f/epicsdbbuilder/dbd.py#L51) is a single `DBEntry` item, which is used as a cursor into a database. However, inside the [ValidateFieldValue](https://github.com/DiamondLightSource/epicsdbbuilder/blob/88ac2802a17b47553bc6591ec56d8b1197645b1f/epicsdbbuilder/dbd.py#L79) method, which can be called from multiple threads simultaneously, the cursor gets re-used for multiple invocations.

This has the end result of creating an error message like this:
```
AssertionError: Can't write "@PV-FROM-CM" to field OUT: fldDes not found
```
Which comes from [this line](https://github.com/DiamondLightSource/epicsdbbuilder/blob/88ac2802a17b47553bc6591ec56d8b1197645b1f/epicsdbbuilder/dbd.py#L91).

This was originally spotted in PythonSoftIOC's scheduled testing, where this error message very occasionally appears during scheduled testing. [See this issue.](https://github.com/DiamondLightSource/pythonSoftIOC/issues/178)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.