Transactions Distribuées
Mécanismes garantissant qu'un ensemble d'opérations sur plusieurs nœuds indépendants réussit entièrement (commit) ou échoue entièrement (rollback) de manière atomique.
Le théorème CAP (Brewer, 2000) : un système distribué ne peut garantir que deux des trois propriétés — Cohérence, Disponibilité, Tolérance aux partitions.
graph LR
Center["Transactions Distribuées"]:::main
Rel_decentralized_derivatives_pricing_models["decentralized-derivatives-pricing-models"]:::related -.-> Center
click Rel_decentralized_derivatives_pricing_models "/terms/decentralized-derivatives-pricing-models"
Rel_transaction_sharding["transaction-sharding"]:::related -.-> Center
click Rel_transaction_sharding "/terms/transaction-sharding"
Rel_decentralized_exchange_dex_order_book["decentralized-exchange-dex-order-book"]:::related -.-> Center
click Rel_decentralized_exchange_dex_order_book "/terms/decentralized-exchange-dex-order-book"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 Explique-moi comme si j'avais 5 ans
Imagine que tu achètes un ticket de concert en ligne. Le site doit faire deux choses en même temps : (1) prélever l'argent de ta banque, (2) te donner le ticket. Si l'ordinateur de la banque prélève l'argent mais que l'ordinateur des tickets plante, tu as payé sans rien recevoir. Une [transaction](/fr/terms/transaction) distribuée est la règle : 'Les deux réussissent, ou les deux sont annulées comme si rien ne s'était passé.' Tout ou rien sur plusieurs ordinateurs.
🤓 Expert Deep Dive
2PC — Protocole Bloquant : Si le coordinateur plante après avoir reçu tous les votes YES, les participants maintiennent des verrous exclusifs indéfiniment. SAGA : Chaque étape T_i a une transaction compensatoire C_i. Un échec à T_3 déclenche C_2, puis C_1. Les SAGAs sacrifient l'Isolation pour la disponibilité. HTLC : Alice verrouille des BTC avec hash(secret), Bob verrouille de l'ETH avec le même hash. Alice révèle le secret pour réclamer l'ETH, ce qui permet à Bob de réclamer les BTC. Théorème CAP : Cohérence vs. Disponibilité lors des partitions réseau.
❓ Questions fréquentes
What is the main problem with Two-Phase Commit (2PC)?
It is a blocking protocol. If the coordinator crashes after collecting all 'YES' votes but before sending the final COMMIT or ABORT decision, all participant nodes freeze, holding database locks indefinitely, until the coordinator recovers.
What is the SAGA pattern and why is it preferred in microservices?
A SAGA breaks a long transaction into smaller local transactions, each with a compensating transaction that undoes it. It avoids distributed locks, making services more available, but sacrifices strict isolation (intermediate states may be visible to other services).
How does a Hash Time Lock Contract (HTLC) enable trustless atomic swaps?
Both parties lock their assets using the same cryptographic secret hash. The first party reveals the secret to claim the other's asset, and this revelation automatically unlocks the secret for the second party to claim the first's asset. If either party doesn't act within the time limit, funds are refunded.