isolation-level

Some clarifications on different Isolation level in database transaction?

↘锁芯ラ 提交于 2019-12-21 05:11:35
问题 Below is the statement written from Wikipedia's Isolation article about REPEATABLE READS In this isolation level, a lock-based concurrency control DBMS implementation keeps read and write locks (acquired on selected data) until the end of the transaction. However, range-locks are not managed, so the phantom reads phenomenon can occur (see below). My question here is when does the the transaction begin and end respectively. If we take the example of Non-repeatable reads with REPEATABLE READS

JPA and MySQL transaction isolation level

两盒软妹~` 提交于 2019-12-19 09:41:10
问题 I have a native query that does a batch insert into a MySQL database: String sql = "insert into t1 (a, b) select x, y from t2 where x = 'foo'"; EntityTransaction tx = entityManager.getTransaction(); try { tx.begin(); int rowCount = entityManager.createNativeQuery(sql).executeUpdate(); tx.commit(); return rowCount; } catch(Exception ex) { tx.rollback(); log.error(...); } This query causes a deadlock: while it reads from t2 with insert .. select , another process tries to insert a row into t2 .

Can multiple threads cause duplicate updates on constrained set?

风格不统一 提交于 2019-12-19 07:35:34
问题 In postgres if I run the following statement update table set col = 1 where col = 2 In the default READ COMMITTED isolation level, from multiple concurrent sessions, am I guaranteed that: In a case of a single match only 1 thread will get a ROWCOUNT of 1 (meaning only one thread writes) In a case of a multi match that only 1 thread will get a ROWCOUNT > 0 (meaning only one thread writes the batch) 回答1: Your stated guarantees apply in this simple case, but not necessarily in slightly more

Repeatable Read - am I understanding this right?

这一生的挚爱 提交于 2019-12-18 13:10:14
问题 Trying to completely understand SQL Server Isolation Levels - notably REPEATABLE READ. I have a sproc that starts a transaction and puts a cursor around some data (boo hiss). This can be a fair chunk of data, so can take a while to do. It will then COMMIT or ROLLBACK. During this time, before the transaction has been closed, if someone calls a method which causes some of those affected rows to be READ, my understanding is that this method will stall until the first method is complete. They

Django transaction isolation level in mysql & postgresql

空扰寡人 提交于 2019-12-18 06:55:11
问题 Do you know the default isolation level of the transactions used in Django? Is it possible to set the isolation level in the database independent way? I'm mainly interested in mysql and postgres. 回答1: You can also change this per client / session using the django database options, like this: DATABASE_OPTIONS = { "init_command": "SET storage_engine=INNODB, SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED", } 回答2: The isolation level isn't changed by mysql drivers so it depends on the server

How to produce phantom reads?

半世苍凉 提交于 2019-12-17 17:55:22
问题 Using "repeatable read" it should be possible to produce a phantom read, but how? I need it for an example teaching CS-students. I think that I must make a "SELECT ... WHERE x<=888" on a non-indexed field x, with an upperlimit 888 not present, and then on another connection insert a new row with a value just below 888. Except it doesn't work. Do I need a very large table? Or something else? 回答1: Erik, I come just from test it with a very large number of rows. You will never found phantoms on

Spring Batch ORA-08177: can't serialize access for this transaction when running single job, SERIALIZED isolation level

故事扮演 提交于 2019-12-17 09:33:48
问题 I am getting this exception with SERIALIZED isolation level on JobRepository in Spring Batch: org.springframework.dao.CannotSerializeTransactionException: PreparedStatementCallback; SQL [INSERT into DATAFEED_APP.BATCH_JOB_INSTANCE(JOB_INSTANCE_ID, JOB_NAME, JOB_KEY, VERSION) values (?, ?, ?, ?)]; ORA-08177: can't serialize access for this transaction ; nested exception is java.sql.SQLException: ORA-08177: can't serialize access for this transaction at org.springframework.jdbc.support

Using NOLOCK Hint in EF4?

夙愿已清 提交于 2019-12-17 07:34:34
问题 We're evaluating EF4 and my DBA says we must use the NOLOCK hint in all our SELECT statements. So I'm looking into how to make this happen when using EF4. I've read the different ideas on how to make this happen in EF4, but all seem like a work around and not sanctioned by Microsoft or EF4. What is the "official Microsoft" response to someone who wants their SELECT statement(s) to include the NOLOCK hint when using LINQ-to-SQL / LINQ-to-Entities and EF4? By the way, the absolute best

Isolation level for single SELECT query with PHP mysqli_query

不羁的心 提交于 2019-12-14 02:36:44
问题 I have an InnoDB database with one table, book . In addition, I have a PHP script which contains one single query, to display the number of books in such book table: SELECT COUNT(*) FROM book As you know, with the mysqli extension, it is possible to create a transaction with mysqli_begin_transaction . Next, the isolation level can be defined. In my case, I don't need transactions related functions, and I use mysqli_query , because it's only a single SELECT query. However, I know that even a

ERROR: duplicate key value violates unique constraint “xak1fact_dim_relationship”

空扰寡人 提交于 2019-12-13 18:05:36
问题 I am getting the below error while deleting some rows and updating the table based on a condition from java. My database is PostgreSQL 8.4. Below is the error: ERROR: duplicate key value violates unique constraint "xak1fact_dim_relationship" The code cuasing this issue is below: /** * Commits job. This does the following: * <OL> * <LI> cancel previous datamart states </LI> * <LI> drop diabled derived objects </LI> * <LI> flip mirror relationships for objects with next states </LI> * <LI>