transactions

How to achieve rollback in transactions in mongo? [closed]

二次信任 提交于 2019-12-18 14:53:16
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I am using mongoose over mongodb. In a request and response from nodejs express server, generally requires a no of queries to mongodb through mongoose. In many cases it may happen, if first a few queries executes successfully and rest all failed under a transaction. Now i need to

How to get a real time within PostgreSQL transaction?

↘锁芯ラ 提交于 2019-12-18 14:00:17
问题 As far as I understand now() returns the same time during the whole PostgreSQL transaction? But how to get real time? Also, I am interested if there any configuration parameter to limit duration of transaction, so that after this period expiration transaction would immediately fail or somehow else prohibit following queries? 回答1: Timeofday() May work for you. 回答2: Use clock_timestamp() . now() is a traditional PostgreSQL equivalent to transaction_timestamp() , which is equivalent to CURRENT

Mysql transaction : commit and rollback

微笑、不失礼 提交于 2019-12-18 13:32:54
问题 I updated my PhpMyAdmin database engine from MyISAM to INNODB to allow rollback. This is my SQL query : START TRANSACTION; UPDATE jkm_content SET state=0 WHERE title IN ('title-1','title2'); And the result : start transaction;# MySQL returned an empty result set (i.e. zero rows). UPDATE jkm_content SET state=1 WHERE title IN ('title-1','title2');# 2 rows affected. 1) So the statement informs me that 2 rows are affected but the change doesn't appear anywhere (neither in my DB nor in the

Atomically set SERIAL value when committing transaction

前提是你 提交于 2019-12-18 13:09:40
问题 Say I have a table where I want to use a serial as primary key to ask for changes from the client. The client will ask "give me the changes after key X". Without using SERIALIZABLE isolation level or locking, this is prone to race conditions. Transaction A can start first, and do its writes, then take a long time to commit. Meanwhile transaction B will start and commit, before A commits. The write from B will get a higher primary key than the write from A. If a client now asks for changes it

PDO, mysql, transactions and table locking

左心房为你撑大大i 提交于 2019-12-18 13:04:25
问题 For fun I am replacing the mysqli extension in my app with PDO. Once in awhile I need to use transactions + table locking. In these situations, according to the mysql manual, the syntax needs to be a bit different. Instead of calling START TRANSACTION, you do it like so... SET autocommit=0; LOCK TABLES t1 WRITE, t2 READ, ...; ... do something with tables t1 and t2 here ... COMMIT; UNLOCK TABLES; (http://dev.mysql.com/doc/refman/5.0/en/lock-tables-and-transactions.html) My question is, how

TransactionScope and Transactions

丶灬走出姿态 提交于 2019-12-18 12:56:10
问题 In my C# code I am using TransactionScope because I was told not to rely that my sql programmers will always use transactions and we are responsible and yada yada. Having said that It looks like TransactionScope object Rolls back before the SqlTransaction? Is that possible and if so what is the correct methodology for wrapping a TransactionScope in a transaction. Here is the sql test CREATE PROC ThrowError AS BEGIN TRANSACTION --SqlTransaction SELECT 1/0 IF @@ERROR<> 0 BEGIN ROLLBACK

Transactions in Redis with read operations

醉酒当歌 提交于 2019-12-18 12:35:28
问题 Using Redis, I want to perform an atomic sequence of commands, i.e. I need to guarantee that no other client will perform changes in the database while the sequence is being executed. If I used write commands only, I could use MULTI and EXEC statements to assure atomicity using transactions. However, I would also like to use read commands in my transactions. Hence I cannot use MULTI , because read commands are also being queued! Basically, in atomic manner, I need to do following: Read x from

Spring multiple transaction managers, single transaction

我与影子孤独终老i 提交于 2019-12-18 12:32:55
问题 I have a complex situation where I have to use 2 different databases, there for I use 2 different transaction managers. Is there a way in Spring to link these transaction managers to work in a single transaction ? In case of an exception on the second dataSource changes on the first should be rolled-back. <bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager" ref="transactionManager"

Magento catching exceptions and rolling back database transactions

ⅰ亾dé卋堺 提交于 2019-12-18 12:27:40
问题 I'm working on a Magento module and need to know if it's possible to roll back a series of model saves. Basically, I have five models plus several from my module that I need to save one after the other: admin/role admin/user core/website core/store_group core/store mymodule/model1 mymodule/model2 My problem is that whenever any of these models throw an exception, I need to go into MySQL and manually delete all the rows that were saved. This is very unproductive. I'm pretty sure that Magento

How JPA transactions works

末鹿安然 提交于 2019-12-18 11:35:19
问题 Following code gets executed whenever I want to persist any entity. Things seems to be working fine but I fail to understand how it works ! EntityManager em = getEntityManager(); EntityTransaction userTransaction = em.getTransaction(); userTransaction.begin(); em.persist( ent ); userTransaction.commit(); The EntityManager above is a single instance shared by whole application. After starting the transaction; I just say em.persist(entity).. How does hibernate know it belongs to which