locking

Using SQL Server as resource locking mechanism

本秂侑毒 提交于 2019-12-24 08:59:15
问题 Given a table of logical resource identifiers (one per row), what is the best way for an arbitrary number of database clients to perform the following operations: Claim access to a specific resource, if it is not already claimed SELECT the next available resource and claim it (similar to above) Release a previously-claimed resource (The table would have a "claimant" column, which would be NULL in unclaimed rows.) I'm stuck on the atomicity of these operations: would I need a whole-table lock

When I set locks in JPA code, are they enforced in code or in DBMS?

那年仲夏 提交于 2019-12-24 08:49:45
问题 If I make a call like this in Java code: entityManager.lock(entity, LockModeType.PESSIMISTIC_WRITE); is this enforced in code, by DBMS table/row-level locks, or either of those depending on the JPA implementation? Thanks! 回答1: JPA rely on dbms to acquire locking on resources. So, yes, it will do row locking on db implementation. That is why we have to specify our db dialect when using JpA. 回答2: This is from the Oracle blog excerpt: The pessimistic lock modes lock a database row when data is

Should I always need to use cflock with SESSION scope variables?

大城市里の小女人 提交于 2019-12-24 08:39:31
问题 I have a simple Form , which on submission sets a variable in SESSION like <cfset SESSION.shownote = 1> After firing an confirmation Email to the user , I am just deleting this variable from the Session. <cfset structdelete(SESSION,"shownote")> Do I really need to user cflock in this case ? I can not think of a Race condition here. As SESSION varies from one user to another , Can anyone please suggest me exactly on which situation we should use cflock with session variables? I have also heard

Coding Style: lock/unlock internal or external?

两盒软妹~` 提交于 2019-12-24 07:35:58
问题 Another possibly inane style question: How should concurrency be locked? Should the executor or caller be responsible for locking the thread? e.g. in no particular language... Caller::callAnotherThread() { _executor.method(); } Executor::method() { _lock(); doSomething(); _unlock(); } OR Caller::callAnotherThread() { _executor.lock() _executor.method(); _executor.unlock() } Executor::method() { doSomething(); } I know little about threading and locking, so I want to make sure the code is

VB.NET Do I need multiple SyncLocks if I want to lock multiple things?

妖精的绣舞 提交于 2019-12-24 06:49:26
问题 VB.NET 2010, .NET 4 Hello all, My question is, imagine I have two List(Of T) objects and a subroutine in a multithreaded environment that modifies both of these objects. I don't understand locks very well, so I'm unsure whether I can just do: SyncLock CType(List1, IList).SyncRoot List1.Clear() List2.Clear() End SyncLock or must I: SyncLock CType(List1, IList).SyncRoot SyncLock CType(List2, IList).SyncRoot List1.Clear() List2.Clear() End SyncLock End SyncLock ? Any insight? Am I even on the

How to lock row in mysql without blocking?

不想你离开。 提交于 2019-12-24 05:49:39
问题 I have a table in mariadb where I save links to some RSS feeds: id | url | done ------------------------------------ 1 | http://example.com/rss | true 2 | http://example.org/rss | false 3 | http://google.com/rss | false When now one process/worker is updating one of the RSS feeds I want it to hide the row from other processes/workers so that they don't do the work twice and deadlock. Using SELECT ... IN SHARE MODE or SELECT ... FOR UPDATE does not work as the row is still visible and will

ReaderWriterLockSlim questions

为君一笑 提交于 2019-12-24 05:45:11
问题 In his answer here, https://stackoverflow.com/a/19664437/4919475 Stephen Cleary mentioned ReaderWriterLockSlim is a thread-affine lock type, so it usually cannot be used with async and await. What did he mean by "usually"? When can ReaderWriterLockSlim be used? Also, I've read here http://joeduffyblog.com/2007/02/07/introducing-the-new-readerwriterlockslim-in-orcas/ that ReaderWriterLockSlim has different quirks, but this article is from 2007. Did it change since then? 回答1: I guess you've

Am I right that InnoDb is better for frequent concurrent updates and inserts than MyISAM?

感情迁移 提交于 2019-12-24 02:39:07
问题 We have a websites with hundreds of visitors every day and tens of thousands queries a day. So, some tables in the database are updated very rarely, some tables are updated few times a minute and some tables are updated ~10 times a seconds. MyISAM uses table-level locking for updates and InnoDb uses row-level locking. So, as I understand, for tables with frequent concurrent updates (several updates per second) it is better to make them InnoDb, and for other tables (if we don't need

Locking to load data to cache

限于喜欢 提交于 2019-12-24 02:06:06
问题 I have a helper class in a web app, and among the things it does is to present common, unchanging data objects as static properties. I'm loading these object as below: public static class MyWebHelper { #region - Constants & Fields private const string LocationCacheKey = "MyWebHelper_Locations"; private static object LocationLoadLock = new object(); private static MemoryCache m_SiteCache; #endregion #region - Properties /// <summary> /// Gets the uneditable collection of locations. /// <

How can I display the activity when device is locked?

纵然是瞬间 提交于 2019-12-24 01:29:10
问题 I want to display one Activity Android, also when I lock my device. Every Time, if I lock my tablet (for example), I should to see one Activity. So, I have built this in AndroidManifest.xml: <activity android:name=".activity.SetupInfoEmergencyActivity" android:label="@string/app_name" android:showOnLockScreen="true" android:screenOrientation="sensorPortrait"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> <