Ticket #4554 (closed: fixed)
Multiple-Reader/Single-Writer locks, or "Busy" flag for workspace access
Reported by: | Janik Zikovsky | Owned by: | Janik Zikovsky |
---|---|---|---|
Priority: | major | Milestone: | Release 2.1 |
Component: | Mantid | Keywords: | |
Cc: | nick.draper@…, russell.taylor@… | Blocked By: | |
Blocking: | Tester: | Vickie Lynch |
Description (last modified by Janik Zikovsky) (diff)
Refs #4516: It is possible to have destructive access to a workspace (via the PlusMD algorithm, for example), while the GUI thread is busy accessing it to draw it.
We can prevent segfaults by either: implementing a "busy" flag on workspaces, or by using Multiple-Reader/Single-Writer locks.
http://stackoverflow.com/questions/989795/example-for-boost-shared-mutex-multiple-reads-one-write
Investigate.
Edit: Here is a sample script that could cause segfaults if using GUI views on the MDW workspace while the loop runs:
import numpy as np CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',MaxRecursionDepth='20',OutputWorkspace='mdw', SplitInto='2', SplitThreshold='150') FakeMDEventData(InputWorkspace='mdw',UniformParams='1e+05') plotSlice('mdw') num = 100 xs = np.random.rand(num)*10.0 ys = np.random.rand(num)*10.0 zs = np.random.rand(num)*10.0 for (x,y,z) in zip(xs, ys, zs): CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',MaxRecursionDepth='20',OutputWorkspace='extra') FakeMDEventData(InputWorkspace='extra',PeakParams='1e4, %g,%g,%g, 0.5'% (x,y,z)) PlusMD('mdw', 'extra', OutputWorkspace='mdw') PlusMD('mdw', 'extra', OutputWorkspace='mdw') PlusMD('mdw', 'extra', OutputWorkspace='mdw') PlusMD('mdw', 'extra', OutputWorkspace='mdw')
Change History
comment:2 Changed 9 years ago by Janik Zikovsky
Refs #4554 trying a boost mutex class, mostly to see if it compiles
Changeset: 5dd3ae31ee4b795c4b87b72e6d081148a8b669ad
comment:3 Changed 9 years ago by Janik Zikovsky
Refs #4554 boost-thread not on windows
Changeset: 88aca9f20aae7e815ec0607cf38c60dd4189d336
comment:4 Changed 9 years ago by Janik Zikovsky
Refs #4554 boost-thread not on windows
Changeset: fec69d95b298326197c3c41b01bbeaca34cca779
comment:5 Changed 9 years ago by Janik Zikovsky
Refs #4554 commented-out test that works for me
Changeset: a44b838fa7322ce14675c456623aa891e0620f35
comment:6 Changed 9 years ago by Janik Zikovsky
Refs #4554 using Poco::RWLock in a test
Changeset: 12d815690785cb94b9ba3cb94e6a74bb3e0aa20d
comment:7 Changed 9 years ago by Janik Zikovsky
Refs #4554 Public ReadLock and private lock access
Also Refs #996: starting to clean up Algorithm.execute()
Changeset: be86fc7198eee110c3d262a25be9213da1b5de06
comment:8 Changed 9 years ago by Janik Zikovsky
Refs #4554 make sure all destructors are virtual and ctors are called
To fix segfaults on destruction. Multiple virtual inheritance is hard ;)
Changeset: 272de2602728e2b4d4b9855305430e0911503757
comment:9 Changed 9 years ago by Janik Zikovsky
Refs #4554 notes for later
Changeset: 1a6622b9c614649f144deca3e9d25b0292c880b9
comment:10 Changed 9 years ago by Janik Zikovsky
Refs #4554 read/write locks on workspaces in Algorithm.
Also refs #996 cleanup
Changeset: ff60eaed87ed19b698f18594b4365b4b9c0568fc
comment:11 Changed 9 years ago by Janik Zikovsky
Refs #4554 make sure to have a unique lock object
when cloning a workspace. So explicitely declared the copy constructors of every class up to DataItem.
Changeset: d6ae8f24b99c22ec2c81cbc597267a1d8617eec1
comment:12 Changed 9 years ago by Janik Zikovsky
Refs #4554 left some debugging statements in
Changeset: c515accbeb966b87ef4eb6ebb9d9b2c2a21e7239
comment:15 Changed 9 years ago by Janik Zikovsky
Refs #4554 added locks to Paraview renderers
To prevent segfaults from algorithms running in the background
Changeset: bb5b66e79c0ab9846386a07909afcb42c7488ca4
comment:16 Changed 9 years ago by Janik Zikovsky
- Status changed from accepted to verify
- Resolution set to fixed
Note to testers: it should be possible to view a MD workspace in VatesSimpleGUI and continually update the settings (so that it fetches the data from the workspace) WHILE the above script runs in the background. The plotting blocks WS modification and vice/versa.
comment:17 Changed 9 years ago by Janik Zikovsky
Refs #4554 added locks to Paraview renderers
To prevent segfaults from algorithms running in the background
Changeset: bb5b66e79c0ab9846386a07909afcb42c7488ca4
comment:18 Changed 9 years ago by Janik Zikovsky
Refs #4554 debugging output for locking
Changeset: dc5a5b22ded47a49b80cb6ffd7d990d697b74eb4
comment:19 Changed 9 years ago by Mathieu Doucet
Re #4554 fix warning
Changeset: 36bc9c4cd1440fde6d1afe7ceadb8141da180d2d
comment:20 Changed 8 years ago by Vickie Lynch
- Status changed from verify to verifying
- Tester set to Vickie Lynch
comment:21 Changed 8 years ago by Vickie Lynch
- Status changed from verifying to closed
Locks work and there is no SegFault in script
comment:22 Changed 5 years ago by Stuart Campbell
This ticket has been transferred to github issue 5401