27
Transacties Theorie mei ’16

Transacties theorie

Embed Size (px)

Citation preview

Transacties Theorie

mei ’16

Resources

Presentatie:

?

Sources:

https://github.com/ninckblokje/transactions-soa12c

De ontdekking van de transactie, nagespeeld in 2016:

https://www.youtube.com/watch?v=Kv7jALjWx5g

JBoss keynote over transacties (aanrader):

https://vimeo.com/16211058

mei ’16 2

Wat is een transactie

“A transaction is a complete unit of work. It may comprise many computational tasks, which may include user interface, data retrieval, and communications.”

mei ’16 3

Wat is een transactie

Atomicity

Consistency

Isolation

Durability

mei ’16 4

Wat is een transactie

try {

begin();

commit();

} catch {

rollback();

}

mei ’16 5

Wat is een transactie

“all activities as part of an operation are either successfully executed and committed together or in case an operation fails, all activities as part of the operation are rolled back”

mei ’16 6

Distributed transaction

“A distributed transaction is a database transaction in which two or more network hosts are involved.”

mei ’16 7

XA transactie

“The goal of XA is to allow multiple resources (such as databases, application servers, message queues, transactional caches, etc.) to be accessed within the same transaction, thereby preserving the ACID properties across applications. XA uses a two-phase commit to ensure that all resources either commit or roll back any particular transaction consistently (all do the same).”

mei ’16 8

XA transactie

• Database

• EJB

• JMS

• MQ

• UMS

• …

mei ’16 9

XA transactie

mei ’16 10

Tran

sact

ion

Man

ager

Application Program

Resource Manager

Resource Manager

Transactionele wijzigingen

Transactie start / einde

Prepare Commit Rollback

Transaction Manager

“A transaction manager is the part of an application that is responsible for coordinating transactions across one or more resources.”

mei ’16 11

Transaction Manager

• Local transaction manager

• Global transaction manager

• Distributed transaction manager

mei ’16 12

Resource Manager

“The Resource Manager manages a particular resource such as a database or a JMS system.”

mei ’16 13

JTA

“The Java Transaction API (JTA) enables distributed transactions to be done across multiple X/Open XA resources in a Java environment”

mei ’16 14

Overzicht (Spring)

mei ’16 15

Overzicht (OC4J)

mei ’16 16

2-Phase Commit

“The two-phase commit protocol (2PC) is a type of atomic commitment protocol (ACP). It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort (roll back) the transaction (it is a specialized type of consensus protocol).”

mei ’16 17

2-Phase Commit

mei ’16 18

2-Phase Commit

Optimalisaties:

• Read-only

• 1-Phase commit

mei ’16 19

Last Resource

“Sometimes it is necessary to allow a non-XA-aware resource manager to participate in a transaction. This is often the case with data stores that do not support distributed transactions. In this situation, you can use a technique known as Last Resource Commit Optimization (LRCO).”

mei ’16 20

Last Resource

mei ’16 21 Commit last resource

WS-Atomic Transaction

“WS-AtomicTransaction defines protocols that enable existing transaction processing systems to wrap their proprietary protocols and interoperate across different hardware and software vendors.”

mei ’16 22

WS-Atomic Transaction <wsdl:definitions

targetNamespace="bank.example.com"

xmlns:tns="bank.example.com"

xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"

xmlns:wsat="http://docs.oasis-open.org/ws-tx/wsat/2006/06"

xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" >

<wsp:Policy wsu:Id="TransactedPolicy" >

<wsat:ATAssertion wsp:optional="true" />

<!-- omitted assertions -->

</wsp:Policy>

<!-- omitted elements -->

<wsdl:binding name="BankBinding" type="tns:BankPortType" >

<!-- omitted elements -->

<wsdl:operation name="TransferFunds" >

<wsp:PolicyReference URI="#TransactedPolicy" wsdl:required="true" />

<!-- omitted elements -->

</wsdl:operation>

</wsdl:binding>

</wsdl:definitions>

mei ’16 23

WS-Atomic Transaction

mei ’16 24

WS-Atomic Transaction

mei ’16 25

SOAP Request

TXN Register

TXN Register Response

SOAP Response

TXN Prepare

TXN Prepare Reponse

TXN Commit

TXN Commit Response

Krak!

• Timeouts

• Crashes

• Racing condities

• Inconsistente staat

• Data zichtbaarheid (?)

mei ’16 26

Eindhoven

De Zaale 11

5612 AJ Eindhoven

Netherlands

Utrecht

Blok D, Graadt van Roggenweg 328-334

3531 AH Utrecht

Netherlands

Sofia Bulgaria

Nikolay Haytov 12

1113 Sofia

Bulgaria

[email protected]

www.syntouch.nl