locking

ORA-08177 with locked table

别等时光非礼了梦想. 提交于 2019-12-11 08:30:14
问题 After a create table l (id int primary key, val int); insert into l values (0, 0); and initializing two oracle sessions alter session set isolation_level=serializable; the following succession leads to a ORA-08177: can't serialize access for this transaction . session 1 session 2 -----------------------------------+----------------------------------- lock table l in exclusive mode -----------------------------------+----------------------------------- lock table l in exclusive mode ----------

File automatically getting locked by IIS 8 (C#, ASP.net mvc razor)

孤街醉人 提交于 2019-12-11 08:14:49
问题 Facing an issue with IIS 8, windows server 2012. Web app written in asp.net c# mvc razor 5 I am facing an File locking(image file) issue by IIS. I have a user profile page where I display the User profile pic. I noticed that as soon as I simply display the profile page in browser, the profile image on disk is locked by the IIS. Profile image is display with a img tag as shown below (Model.ImagePath is a string path) string ImageUrl = ""; if (Model.ImagePath == null || Model.ImagePath == "

How to handle concurrent inserts into DB causing violation of a rule for the records in the database?

不羁的心 提交于 2019-12-11 06:58:12
问题 We have a CARD table that stores card number and user account number. Only a max of two users can share the same card. This constraint is not implemented as an SQL constraint on the table but is imposed in the code in the following way. When a user tries to add a card - check whether the card number already exists in the DB. Done by querying the table with the card number. If no records, it means it is a new card. Add a record. If there are already records - if the no. of records is less than

How do I use LockService properly every time in Google Apps Script?

故事扮演 提交于 2019-12-11 06:35:33
问题 I am trying to avoid concurrent process with LockService on my project. In test runs, LockService works for me without any problems. But when I roll my project out, sometimes LockService doesn't seem to work properly and overwrite spreadsheet values. I used tryLock() and hasLock() methods to acquire a lock. function test(array) { var lock = LockService.getScriptLock(); if (lock.tryLock(500)) { if (!lock.hasLock()) { var message = "Another user is submitting form data. Please try again later."

clang doesn't support atomic::is_lock_free for types larger than 32 bits?

☆樱花仙子☆ 提交于 2019-12-11 06:25:21
问题 I've got the following: struct A { int a[4]; }; struct B { int x, y; }; int main() { std::cout << std::boolalpha << "std::atomic<A> is lock free? " << std::atomic<A>{}.is_lock_free() << '\n' << "std::atomic<B> is lock free? " << std::atomic<B>{}.is_lock_free() << '\n'; } It compiles and works well, but if I raise the size of A: struct A { int a[5]; }; struct B { int x, y; }; int main() { std::cout << std::boolalpha << "std::atomic<A> is lock free? " << std::atomic<A>{}.is_lock_free() << '\n'

C# \ Lock \ lock instance member VS lock static member

天大地大妈咪最大 提交于 2019-12-11 06:24:37
问题 what is better? is there any difference in runtime between the two options? 回答1: There is no runtime difference between locking a static and locking an instance member. However, it can break your code if you use an instance lock and are updating a static. class Broken { static int myCounter; object synch = new object(); void SomeMethod() { lock (synch) { // BAD ++myCounter; } } } 回答2: Huh? I thought it should depend on what you are locking for. If you are trying to lock a non-static object,

How come a page can be both intent share(IS) and intent exslusive(IX)

五迷三道 提交于 2019-12-11 06:16:00
问题 I'm new to TSQL, still struggling in understanding some basic concepts: My textbook provides an example: there three session(3 query windows, I will refer to them as Connection 1, Connection 2, and Connection 3) Run the following code in Connection 1 to update a row in the Production.Products table, adding 1.00 to the current unit price of 19.00 for product 2. BEGIN TRAN; UPDATE Production.Products SET unitprice += 1.00 WHERE productid = 2; Run the following code in Connection 2 to try to

How to lock a long async call in a WebApi action?

 ̄綄美尐妖づ 提交于 2019-12-11 06:08:13
问题 I have this scenario where I have a WebApi and an endpoint that when triggered does a lot of work (around 2-5min). It is a POST endpoint with side effects and I would like to limit the execution so that if 2 requests are sent to this endpoint (should not happen, but better safe than sorry), one of them will have to wait in order to avoid race conditions. I first tried to use a simple static lock inside the controller like this: lock (_lockObj) { var results = await _service

Would such class be readable only once a Set by multiple threads?

不羁岁月 提交于 2019-12-11 05:58:30
问题 So having a class like: class mySafeData { public: mySafeData() : myData(0), changed( false ) { } void Set(int i) { boost::mutex::scoped_lock lock(myMutex); myData = i; // set the data changed = true; // mark as changed myCondvar.notify_one(); // notify so a reader can process it } void Get( int& i) { boost::mutex::scoped_lock lock(myMutex); while( !changed ) { myCondvar.wait( lock ); } i = myData; changed = false; // mark as read myCondvar.notify_one(); // notify so the writer can write if

Is there a way i can get the java.util.concurrent.locks.ReentrantReadWriteLock object from java.util.concurrent.locks.ReentrantReadWriteLock$ReadLock

让人想犯罪 __ 提交于 2019-12-11 05:34:20
问题 I create a java.util.concurrent.locks.ReentrantReadWriteLock using new java.util.concurrent.locks.ReentrantReadWriteLock().readLock() and then I pass to a method as Lock interface method(Lock lock) Now I want to find how many readlocks are possessed by the current thread. How can i achieve this? I can't cast it again into ReentrantReadWriteLock . What should I do? How I can get this count? 回答1: To get the read lock count on the ReentrantReadWriteLock, you need to call lock.getReadHoldCount()