当前位置:网站首页>Transactional transaction propagation behavior?
Transactional transaction propagation behavior?
2022-07-26 12:42:00 【User 9919783】
Transaction propagation behaviors include 7 Kind of , Not interacting with the database , Database defined , It is spring The frame comes with .
This article mainly introduces three kinds of :required、nested、required_new.
Propagation_required( Communication requirements ): default , The most common , If there is no current transaction , Execute on the new transaction , If any , Join the current transaction execution . When the peripheral method does not open a transaction , Two internal transactions start this transaction without interfering with each other , And not affected by peripheral abnormalities .
Under the default propagation requirements , If an exception is caught in the inner transaction , Then other programs in this inner transaction run normally . Peripheral transactions caught exceptions , Peripheral and other internal transactions cannot run normally .
Propagation_supports( Communication support ): Support current transaction , If there is no business , It's non transactional .Propagation_mandatory( mandatory ): If there are currently no transactions , Throw an exception .
Propagation_requires_new: New transaction , If a transaction currently exists , Suspend the current transaction . When the peripheral method does not open a transaction , Two internal transactions start this transaction without interfering with each other , And not affected by peripheral abnormalities .
If the peripheral starts a transaction ,requeired Inner transactions and outer transactions are rolled back at the same time .
if requreis_new Inner transaction exception is not caught , be requeired The inner transaction and outer transaction are rolled back together , other requreis_new Internal affairs are not affected .
if requreis_new The inner transaction exception is trycatch Capture , Then other peripheral affairs will not be affected .
Propagation_not_supported( Not supported ): Operate with non transaction , If a transaction currently exists , Let the transaction hang .
Propagation_never: To execute in a non transactional manner , If a transaction currently exists , Throw an exception .
Propagation_nested( Propagate nesting ): If there are currently transactions , Then execute within the nest , If there is no transaction , execute Propagation_required operation . When the peripheral method does not open a transaction , Two internal transactions start this transaction without interfering with each other , And not affected by peripheral abnormalities .
1、propagaration_requeire_new And Propagation_nested The difference between nested propagation :
Nested If peripheral transactions are enabled , Because it is a parent-child nested transaction , Then the sub transactions are rolled back with the rollback of the peripheral main transaction , If the sub transaction rolls back, all transactions will be rolled back together , Unless the current sub transaction is trycatch Capture . and requeires_new Peripheral transactions and inner transactions are two transactions , Rollback of peripheral transactions does not affect internal transactions .
2、Nested and requeired difference :
Will roll back with the rollback of peripheral transactions .Requeired It belongs to joining peripheral affairs , Because they all belong to the same transaction , Once the inner transaction is rolled back, whether or not trycatch Capture , All rolled back together . and nested It belongs to sub transaction , There is a separate save node , therefore nested Method throws an exception trycatch Capture is rolled back , It will not affect peripheral affairs .
The code example is as follows :
required example , Use the default transaction instance , Whether or not exceptions are caught , Roll back all together
nested example , Because nested transactions , The outer and inner walls will roll back with each other , Unless the sub transaction is caught exception
required_new example , When the periphery throws an exception , It will not affect the normal storage of internal businesses in the database
边栏推荐
- Redis主从复制原理
- Examples of ThreadLocal usage scenarios under multithreading
- Removable tablespace
- The programmed navigation route jumps to the current route (the parameters remain unchanged), and if it is executed multiple times, it will throw a navigationduplicated warning error?
- .eslintrc.js配置说明
- Analysis of Wireshark data package of network security B module of national vocational college skills competition Wireshark 0051.pcap
- Yolov7 training dangerous goods identification pytorch
- 海外APP推送(下篇):海外厂商通道集成指南
- How RFID works
- Understand test.py in gaitset
猜你喜欢

STM32驱动HC05蓝牙串口通信模块

How RFID works

How do children's playgrounds operate?

File类的学习过程中出现的问题及解决方法

回溯——第51题. N皇后——必须攻克的经典回溯难题

LCD notes (4) analyze the LCD driver of the kernel

Digital intelligence transformation, management first | jnpf strives to build a "full life cycle management" platform

连锁店收银系统如何帮助鞋店管理好分店?

敲黑板画重点:七种常见“分布式事务”详解

新功能 | 智能开放搜索上线定制词权重模型
随机推荐
Kubernetes----安装部署NFS服务器
数字化时代,是什么“黄金宝藏”在推动百年药企发展?
食品安全 | 随便果可以”随便“吃吗?
2022.7.23 ------ leetcode. Jianzhi offer.115
LCD notes (5) LCD driver framework_ Use device tree
Data query of MySQL (aggregate function)
什么是回调函数,对于“回”字的理解
X.509、PKCS文件格式介绍
可移动表空间
The programmed navigation route jumps to the current route (the parameters remain unchanged), and if it is executed multiple times, it will throw a navigationduplicated warning error?
14.2 byte stream learning
Transformer dominates the world? Depth wise conv has something to say
Overseas app push (Part 2): Channel Integration Guide for overseas manufacturers
敲黑板画重点:七种常见“分布式事务”详解
10. 509. Introduction to PKCs file format
2022 年要了解的新兴安全供应商
How do children's playgrounds operate?
Emerging security providers to learn about in 2022
Minesweeping games - easy to play addictive (C language version)
什么是物联网?常见IoT协议最全讲解