分散トランザクション
□未翻訳
□翻訳中
■翻訳完了(細田謙二)
■レビュー(Omi Chiba)
分散トランザクション
執筆時点では、この機能はPostgreSQL、MySQL、Firebirdに対してのみサポートされています。これらは2相コミットのAPIを公開しているためです。
At the time of writing this feature is only supported by PostgreSQL, MySQL and Firebird, since they expose API for two-phase commits.
個別のPostgreSQLデータベースに接続する2つ(またはそれ以上)の接続を持っていると仮定します:
Assuming you have two (or more) connections to distinct PostgreSQL databases, for example:
モデルやコントローラにおいて、それらを同時にコミットすることが可能です:
In your models or controllers, you can commit them concurrently with:
失敗した場合は、この関数はロールバックして、Exceptionを発生させます。
On failure, this function rolls back and raises an Exception.
コントローラにおいて、1つのアクションが返されると、もし2つの別個の接続を持ち、かつ、上記の関数を呼び出していない場合は、web2pyはそれらを個別にコミットします。これは、1つのコミットが成功し、もう一つが失敗するという可能性があることを意味します。分散トランザクションはこのようなことが起こるのを防ぎます。
In controllers, when one action returns, if you have two distinct connections and you do not call the above function, web2py commits them separately. This means there is a possibility that one of the commits succeeds and one fails. The distributed transaction prevents this from happening.