transactions

Transactional file writing in C# and Windows?

試著忘記壹切 提交于 2020-01-03 07:14:12
问题 I have a data file and from time to time I need to write a change to the file. The change consists of changing information in more than one place. For example, changing some data near the end of the file and also changing some information near the start. I want the two separate writes to either both succeed or both fail, otherwise it is left in uncertain state and effectively corrupted. Is there any builtin support for this scenario in .NET or in general? If not then how to others solve this

Transaction “REQUIRED” propagation in Spring

泪湿孤枕 提交于 2020-01-03 05:17:29
问题 I'm new to Spring and I'm not able to make the transaction propagation in "REQUIRED" mode. Here is an example: @Controller public class ExampleController { @Autowired Foo foo; @Autowired Bar bar; @RequestMapping(value = "/example") public String submitForm(Model model) throws Exception { User user = new User("Joe", "Bloggs"); user = foo.save(user); bar.simpleMethod(user); return "success"; } } @Repository public class Foo { // A JPA repository private EntityManager em; @Transactional

How can have a SQL connection that is sleeping a pending transaction?

戏子无情 提交于 2020-01-03 03:39:07
问题 I'm facing some locks at our DB server created by our application. What I don't understand is how a process that is Sleeping is having an Open Transaction (that process 71 is the one creating the Lock). As far as I know when a process finishes it closes all the opened transactions. Is that rigth? Thanks in advance mates. 回答1: As far as I know when a process finishes it closes all the opened transactions. Is that right? No. If you explicitly open a transaction you must explicitly commit or

JPA update query without transaction - is transaction mandatory?

…衆ロ難τιáo~ 提交于 2020-01-03 03:16:27
问题 I'm trying to do insert via a native query with JPA, but I don't want to create a transaction: Query query = em.createNativeQuery("INSERT INTO person (id, firstname, lastname) VALUES ('1','Ronnie','Dio')"); int count = query.executeUpdate(); this ends up with the TransactionRequiredException: javax.persistence.TransactionRequiredException: Executing an update/delete query at org.hibernate.ejb.AbstractQueryImpl.executeUpdate(AbstractQueryImpl.java:99) However, if I unwrap the Hibernate session

redis and watch + multi allows concurrent users

ⅰ亾dé卋堺 提交于 2020-01-03 02:59:33
问题 I'm doing a load test on user signup with the same email address for a webservice and the first 10 users which connect simultaneously will always register. I'm using WATCH and MULTI but that doesn't seem to work any way. I'm calling save() to save the user. this.insert = function(callback) { this.preInsert(); created = new Date(); updated = new Date(); // Also with these uncommented it still doesn't work // Common.client.watch("u:" + this.username); // Common.client.watch("em:" + this.email);

redis and watch + multi allows concurrent users

一曲冷凌霜 提交于 2020-01-03 02:59:32
问题 I'm doing a load test on user signup with the same email address for a webservice and the first 10 users which connect simultaneously will always register. I'm using WATCH and MULTI but that doesn't seem to work any way. I'm calling save() to save the user. this.insert = function(callback) { this.preInsert(); created = new Date(); updated = new Date(); // Also with these uncommented it still doesn't work // Common.client.watch("u:" + this.username); // Common.client.watch("em:" + this.email);

MySQL: Invoke trigger after transaction is committed

前提是你 提交于 2020-01-03 02:24:06
问题 I've a very simple database with following schema: video (id, title, description) category (id, name) tag (id, name) video_category_reference (video_id, category_id) video_tag_reference(video_id, tag_id) abc_table (video_id, description, categories) The first five tables use InnoDB engine. The last table - abc_table uses MyISAM engine and it contains some kind of "cache". description column stores the result of CONCAT(video.title, video.description, GROUP_CONCAT(tag.name)) and categories

Render failing to render correct template in rescue_from ActiveRecord::Rollback method

瘦欲@ 提交于 2020-01-02 23:59:24
问题 I'm building the checkout page for an e-commerce site, and I have a fairly long transaction that creates a new User model and a new Order model. I wrapped the creation of these models in a transaction so that if validation for one fails, the other isn't hanging around in the database. Here's the trimmed-down code in my OrdersController: rescue_from ActiveRecord::Rollback, with: :render_new def render_new render action: 'new' end ActiveRecord::Base.transaction do @user = User.new params[:user]

How locks (S,X,IS,IX) work in Mysql with queries like FOR UPDATE/LOCK IN SHARE MODE?

落花浮王杯 提交于 2020-01-02 18:08:11
问题 1: I was trying this and it was working fine: start transaction; select * from orders where id = 21548 LOCK IN SHARE MODE; update orders set amount = 1500 where id = 21548; commit; According to the definition of LOCK IN SHARE MODE , it locks the table with IS lock and lock the selected rows with S lock. When a row is locked with S lock.How can it be modified without releasing lock? It needs X lock to modify it.Right? Or is it valid only for different connection transaction? 2: //session1

IndexedDb transaction auto-commit behavior in edge cases

微笑、不失礼 提交于 2020-01-02 16:22:13
问题 Tx is committed when : request success callback returns - that means that multiple requests can be executed within transaction boundaries only when next request is executed from success callback of the previous one when your task returns to event loop It means that if no requests are submitted to it, it is not committed until it returns to event loop. These facts pose 2 problematic states : placing a new IDB request by enqueuing a new task to event loop queue from within the success callback