Skip to content
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

Multithreaded access error when validating fields #32

Open
AlexanderWells-diamond opened this issue Dec 3, 2024 · 2 comments
Open

Multithreaded access error when validating fields #32

AlexanderWells-diamond opened this issue Dec 3, 2024 · 2 comments

Comments

@AlexanderWells-diamond
Copy link

It seems that part(s) of epicsdbbuilder are not threadsafe. Inside of ValidateDbField is a single DBEntry item, which is used as a cursor into a database. However, inside the ValidateFieldValue 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.

This was originally spotted in PythonSoftIOC's scheduled testing, where this error message very occasionally appears during scheduled testing. See this issue.

@Araneidae
Copy link
Collaborator

Do we have a nice performance regression test for pythonIoc? I remember in the past having to be quite clever about locking to avoid a serious performance bottleneck in the startup of a large soft IOC (there's a slightly cryptic comment about this in one of the code bases, but I can't remember where right now). I can think of a couple of fixes for the cursor problem, but it would be good to be confident that they won't cause performance regression.

The fixes are one of:

  1. Add a mutex
  2. Remove the shared cursor and regenerate it on every use (I think this is compatible with how the function is used, but needs checking).

Both of these have potential performance impact.

@AlexanderWells-diamond
Copy link
Author

We have no performance testing for PythonSoftIOC. It's quite hard to set one up, especially one to run in CI, due to the sheer number of variables to control.

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

No branches or pull requests

2 participants