+ All Categories
Home > Documents > Logging Last Resource Optimization for Distributed Transactions in Oracle Weblogic Server

Logging Last Resource Optimization for Distributed Transactions in Oracle Weblogic Server

Date post: 22-May-2015
Category:
Upload: german-gera-shegalov
View: 812 times
Download: 1 times
Share this document with a friend
Popular Tags:
29
Logging Last Resource Optimization for Distributed Transactions in Oracle WebLogic Server T. Barnes, A. Messinger, P. Parkinson, A. Ganesh, G. Shegalov, S. Narayan, S. Kareenhalli
Transcript
Page 1: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Logging Last Resource Optimization for Distributed Transactions in

Oracle WebLogic Server

T. Barnes, A. Messinger, P. Parkinson, A. Ganesh, G. Shegalov, S. Narayan, S. Kareenhalli

Page 2: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

OLTP: Online Transaction Processing

Transaction is an ACID contract● Atomic – all or nothing

● Consistent – from the application perspective

● Isolated – masked concurrency through locking or snapshots

● Durable – once committed changes survive subsequent failures

Checking = 2000Savings = 8000

Checking = 1000Savings = 9000

time

beginc -= 1000s += 1000commit

Page 3: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

OLTP: Single Resource● A and D are typically implemented using Write-Ahead Logging

● Transaction recovery is “simple”: REDO phase, UNDO phase.BEGIN TRANSACTION

/* LSN = 1: log for undo and redo in MM buffer*/

UPDATE Accounts SET balance = balance – 1000 WHERE Number = 1

/* LSN = 2: log for undo and redo in MM buffer*/

UPDATE Accounts SET balance = balance + 1000 WHERE Number = 2

/* LSN = 3: log commit and force (5-6 orders slower)*/

COMMIT TRANSACTION

Accounts LSN=1

1 1000

2 8000

Accounts LSN=2

1 1000

2 9000

Accounts LSN=0

1 2000

2 8000

Page 4: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

OLTP: Distributed / Two-Phase Commit

Transaction Coordinator

Resource 1 Resource 1

prepare --> force-log prepare force-log prepare

<-- OK <-- OK

commit --> force-log commit force-log commit

<-- ACK <-- ACK

Like a wedding ceremony

Coordinator: Will you ...? (prepare)

Resource: I will (OK)

Coordinator: I pronounce you … (commit)

Page 5: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

2PC is A CI D

● 2PC is not about Concurrency Control.

● 2PC transaction is therefore

○ Globally Atomic

○ Locally Isolated

○ Locally Consistent

○ Globally Durable

Page 6: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

OLTP: Queued Transactionsclient` app server database

begin transaction

req_q.enqueue(req1)

commit transaction

begin transaction

creq = req_q.dequeue()

resp = creq.execute()

res_q.enqueue(resp)

commit transaction

begin transaction

resp = res_q.dequeue()

process(resp)

commit transaction

Page 7: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

WebLogic Server: Java EE++

● App containers: Web (Servlets, WS), EJB, app clients

● Services: Messaging (JMS),

Transactions (JTA), Database (JDBC), …

Page 8: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Example: Queued Transactions (JEE)

@MessageDriven(

mappedName="jms/inboundQueue“

activationConfig = {@ActivationConfigProperty(

propertyName = “connectionFactoryJndiName",

propertyValue = “jms/inboundConnectionFactory"

)}))

@TransactionAttribute(TransactionAttributeType.REQUIRED)public class OrderMDB implements javax.jms.MessageListener {

@Resource javax.jms.Queue outboundQueue; @Resource javax.jms.ConnectionFactory outboundCf; @Resource javax.sql.DataSource orderDataSource; public void onMessage(Message message) { java.sql.Connection jdbc = orderDataSource.getConnection();

javax.jms.Connection jms = outboundCf.createConnection();

// update SQL via JDBC, notify via JMS connections …

}

}

Page 9: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

“School” Presumed Abort 2PC TM Resources

Timeline

prepare

yes

force-log prepared

commit

force-log commit

all-prepared: force-log commit

all-commit: log end

ack

2n+1 writes, 4n messages

Page 10: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

PA2PC (1): TM (Coordinator)

Page 11: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

PA2PC (2): Resource (Participant)

Page 12: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

“Real Life” XA 2PC

TM Resources

Timeline xa_prepare

ack_preparedforce-log prepared

xa_commitforce-log commit

all-prepared: force-log commit

all-commit: log end

ack_committed

xa_startack_started

ack_endedxa_end

2n+1 writes, 8n messages

Page 13: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Standard 2PC Optimizations

● 1PC: if only one resource enlisted, prepare skipped

● Read-Only: if voted read-only, commit skipped

● XA ceremony of xa_(start|end) is always present

Page 14: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Nested 2PC: Coordinator Role Transfer

TC Res2 Res3

prepare commit

commitcommit

● Last Resource is committed in one phase

● 2n messages/ 2n-1 forced writes

● Known topology: linked Databases

[Gray’78]

p

c

c

Page 15: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

WebLogic Design Constraints and Goals

● No control over foreign XAResource, TM and topology

● Broadband: minimize blocking RPC, not messages

● Unneeded XA on Res3: save xa_start, xa_end

Page 16: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Typical WLS Deployment

● JMS and TM share the same FileStore

● Collocated JMS connection cost is negligible

● JDBC Datasource is remote: blocking RPC

● DB internal resources (locks, latches, etc.) are more

expensive and JEE is not a single client

● Outbound JMS notifies about a JDBC update

● Ideally: JDBC updates visible before JMS updates

Page 17: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

JDBC as Logging Last Resource

● User enables a non-XA JDBC Datasource as LLR

○ LLR table WL_LLR_<server> in the DS schema

○ No XA overhead for the LLR

● TM log is local log UNION LLR table log

○ WLS does not boot if any LLR table is unavailable

● Restriction: 1 LLR datasource / Transaction

● No coordinator transfers as in Nested 2PC

Page 18: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

XA 2PC Commit with LL Resource

1. Prepare concurrently all non-LLR XAResources

2. Insert XID into the LLR table

3. Commit the LLR-Resource

4. If 3 is successful, commit non-LLR XAResources

5. Lazy garbage-collection of 2PC records of completed

transactions is piggybacked on future LLR transactions

Page 19: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

LLR Failure Recovery

● Failure before LLR.commit() => global abort

● Failure during LLR.commit() => similar to media failure

○ Wait until LLR Datasource / table is available for read

○ Presence of the LLR commit log decides the global outcome

○ If unavailable for AbandonTimeoutSeconds log abandoned

● JVM/OS crash: TM scan local log UNION LLR

○ Usual transaction outcome resolution

● 2PC recovery guarantees are not compromised

Page 20: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

LLR Savings

Back-of-the-envelope for the single-threaded case with Jeff Dean’s numbers [Google key notes]: ● xa_start (RPC),

● xa_end (RPC),

● xa_prepare (RPC + force-log)

● Insert into LLR table + commit done via single RPC

------------------------------------------------4xRTT + 1xDiskSeek = 4x500,000ns + 10,000,000ns = 12 milliseconds

Page 21: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

LLR in DS Wizard: Non-XA Driver

Page 22: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

LLR in DS Wizard: Safe unlike Emulate

Page 23: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Research Workload EAStress2004 [SPECjAppServer’04]

Page 24: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

EAStress2004 Benchmark HW/Setup

Driver 1 (3x Dealer, 3x Manufacturing)

Driver 2 (3x Dealer, 3x Manufacturing)

External Supplier Emulator

2x Quad Core 3.7Ghz x86_64, 2MB L2, 8GB RAM

2x Quad Core 2.7Ghz x86_64, 2MB L2, 16GB RAM

2x Quad Core 2.7Ghz x86_64, 2MB L2, 16GB RAM

System Under Test

Oracle WebLogic Server 11gR1 (Middle Tier)

Oracle RDBMS 11gR1 EE(Database Tier)

2x Quad Core 2.83Ghz x86_64, 6MB L2, 16 GB RAM

4x Quad Core 2.7Ghz x86_64, 2MB L2, 64GB RAM

Page 25: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Performance Evaluation (Utilization)

MDB scenarioMT = WLS on JrockItDB = Oracle Database

EAStess2004 v1.08, IR = 700 (not reviewed by SPEC)

Page 26: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Performance Evaluation (Response Time)EAStess2004 v1.08, IR = 700 (not reviewed by SPEC)

Purchase Manage Browse Manufacturing

XA 4.20 2.40 5.40 3.75

LLR 1.50 1.20 1.90 3.00

improvement 2.8x 2x 2.8x 1.25x

Page 27: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Future Improvements (probably in 12c)

● LLR does not detect Read-Only

● Transaction GUID instead of LLR table for Oracle

Page 28: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

Thank You. Questions?

oracle.com/weblogicoracle.com/benchmarks

Page 29: Logging Last Resource Optimization for Distributed Transactions in  Oracle Weblogic Server

WebLogic FileStore

● XA-capable KV store on local file system

● Mime design: allocate under write-head

○ fast writes

○ slow recovery

○ works well up to a couple of GiB

● Transactional use: for JMS messages and JTA logs

● Non-transactional use: Diagnostics and Config


Recommended