SQL Server – How to lock a table until a stored procedure finishes

Needed this answer myself and from the link provided by David Moye, decided on this and thought it might be of use to others with the same question: CREATE PROCEDURE … AS BEGIN BEGIN TRANSACTION — lock table “a” till end of transaction SELECT … FROM a WITH (TABLOCK, HOLDLOCK) WHERE … — do some … Read more

To what level does MongoDB lock on writes? (or: what does it mean by “per connection”

MongoDB Locking is Different Locking in MongoDB does not work like locking in an RDBMS, so a bit of explanation is in order. In earlier versions of MongoDB, there was a single global reader/writer latch. Starting with MongoDB 2.2, there is a reader/writer latch for each database. The readers-writer latch The latch is multiple-reader, single-writer, … Read more

Destination Array not long enough?

I would say the error lies in the object _bikes not being thread safe. As commented, somewhere there is a modify of the _bikes object that is not being lock’ed. It is a split second error where the variable bs is set up to a size X when the size of _bikes is measured. In … Read more

What’s the difference between PESSIMISTIC_READ and PESSIMISTIC_WRITE in JPA?

The difference lies in locking mechanism. PESSIMISTIC_READ lock means that dirty reads and non-repeatable reads are impossible when you have such a lock. If data should be changed it’s required to obtain PESSIMISTIC_WRITE lock PESSIMISTIC_WRITE lock guarantees that besides dirty and non-repeatable reads are impossible you can update data without obtaining additional locks(and possible deadlocks … Read more

Using WITH NOLOCK Table Hint in Query Using View – Does it Propagate Within the View?

Yes, NOLOCK will propagate to the tables used by the view definition (at least in SQL Server 2005). See Table Hints in MSDN: In SQL Server 2005, all lock hints are propagated to all the tables and views that are referenced in a view. Also, SQL Server performs the corresponding lock consistency checks. However, If … Read more

Simple Java name based locks?

All those answers I see are way too complicated. Why not simply use: public void executeInNamedLock(String lockName, Runnable runnable) { synchronized(lockName.intern()) { runnable.run(); } } The key point is the method intern: it ensures that the String returned is a global unique object, and so it can be used as a vm-instance-wide mutex. All interned … Read more

Show all current locks from get_lock

From MySQL 5.7 onwards, this is possible, but requires first enabling the mdl instrument in the performance_schema.setup_instruments table. You can do this temporarily (until the server is next restarted) by running: UPDATE performance_schema.setup_instruments SET enabled = ‘YES’ WHERE name=”wait/lock/metadata/sql/mdl”; Or permanently, by adding the following incantation to the [mysqld] section of your my.cnf file (or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)