问题
I'm considering to set up a symbol store for our team and extend our packaging infrastructure so that debug symbols automatically get added to the store. The idea was that once a build is finished, we run symstore
on the build directory and have it merge all the .pdb
files into the symbol store. In principle, this appears to be fairly straightforward to do but there's one issue:
The page on using SymStore explains that
SymStore does not support simultaneous transactions from multiple users. It is recommended that one user be designated "administrator" of the symbol store and be responsible for all add and del transactions.
This is a problem because we have plenty of build machines, and it's perfectly possible that two (independant) builds finish at roughly the same time and hence try to update the symbol store in parallel.
I can think of various ways to ensure that there's always only one symstore
process updating the symbol store, but before I roll my own synchronization method I wonder:
Is there a (quasi) standard or very conventional way of updating a symbol store in a way which ensures that there aren't multiple concurrent transactions? In particular, it appears that it's possible to write your own symbol store creation program, maybe there's a popular alternative which does handle synchronization using some sort of lock or so? I imagine other teams must have hit (and hopefully) solved this problem already.
回答1:
I ended up writing a little utility withlockfile which I can use to synchronize adding transactions to the symbol store. The idea is that instead of
symstore add ... /s \\myserver\symbols
I wrap the invocation in a withlockfile
call which will suspend until it can acqure a lock file. The lock file is stored in the actual symbol storage. So my above call becomes
withlockfile \\myserver\symbols\lockfile.txt symstore add ... /s \\myserver\symbols
This command is executed after our builds, since all withlockfile
calls use the same (shared) lock file, no two symstore
invocations run concurrently.
来源:https://stackoverflow.com/questions/21149366/how-do-you-synchronize-updates-to-a-windows-symbol-store