blob: b9a35685902d6c98d32c23bbea496d2a3a03361c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
<!DOCTYPE html>
<html>
<head>
<title>
The Codex »
MySQL's Two-Phase Commit Implementation Is Broken
</title>
<link
rel='stylesheet'
type='text/css'
href='http://fonts.googleapis.com/css?family=Buenard:400,700&subset=latin,latin-ext'>
<link
rel="stylesheet"
type="text/css"
href="../media/css/reset.css">
<link
rel="stylesheet"
type="text/css"
href="../media/css/grimoire.css">
</head>
<body>
<div id="shell">
<ol id="breadcrumbs">
<li class="crumb-0 not-last">
<a href="../">index</a>
</li>
<li class="crumb-1 not-last">
<a href="./">mysql</a>
</li>
<li class="crumb-2 last">
broken-xa
</li>
</ol>
<div id="article">
<h1 id="mysqls-two-phase-commit-implementation-is-broken">MySQL's Two-Phase Commit Implementation Is Broken</h1>
<p>From <a href="http://dev.mysql.com/doc/refman/5.5/en/xa-restrictions.html">the fine
manual</a>:</p>
<blockquote>
<p>If an XA transaction has reached the PREPARED state and the MySQL server is
killed (for example, with kill -9 on Unix) or shuts down abnormally, the
transaction can be continued after the server restarts. However, if the
client reconnects and commits the transaction, the transaction will be
absent from the binary log even though it has been committed. This means the
data and the binary log have gone out of synchrony. An implication is that
<strong>XA cannot be used safely together with replication</strong>.</p>
</blockquote>
<p>(Emphasis mine.)</p>
<p>If you're solving the kinds of problems where two-phase commit and XA
transaction management look attractive, then you very likely have the kinds of
uptime requirements that make replication mandatory. “It works, but not with
replication” is effectively “it doesn't work.”</p>
<blockquote>
<p>It is possible that the server will roll back a pending XA transaction, even
one that has reached the PREPARED state. This happens if a client connection
terminates and the server continues to run, or if clients are connected and
the server shuts down gracefully.</p>
</blockquote>
<p>XA transaction managers assume that if every resource successfully reaches the
PREPARED state, then every resource will be able to commit the transaction
“eventually.” Resources that unilaterally roll back PREPARED transactions
violate this assumption pretty badly.</p>
</div>
<div id="comments">
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'grimoire'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
<div id="footer">
<p>
The Codex —
Powered by <a href="http://markdoc.org/">Markdoc</a>.
<a href="https://bitbucket.org/ojacobson/grimoire.ca/src/master/wiki/mysql/broken-xa.md">See this page on Bitbucket</a> (<a href="https://bitbucket.org/ojacobson/grimoire.ca/history-node/master/wiki/mysql/broken-xa.md">history</a>).
</p>
</div>
</div>
</body>
</html>
|