[pgsql-jp: 31793] Re: PGCluster-1.0.6リリースしました
TANIDA Yutaka
tanida @ sra.co.jp
2003年 12月 15日 (月) 15:28:25 JST
谷田です。追試してみました。
On Fri, 12 Dec 2003 22:14:55 +0900
Wataru Oguro <oguro @ zenrin-datacom.net> wrote:
> -------
> begin;
> update test set a = 'test2' where a = 'test2';
> commit;
> -------
> というSQLをPHPに組み込み、アパッチベンチで実行しました。
こちらでは簡単なJavaのプログラムを書きました。プログラム自体は末尾に添付
しておきますので、追試する方は適当に書き換えてご利用ください。
確かにたまに更新が停止してしまうようです。個人的にはレプリケーションサー
バー内の競合のように思えます。
--
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
/**
* test assumes :
* create database tanida;
* create user tanida;
* create table test (t text);
* update test set t='test' where t='test';
*
*
* @author yutaka
*
*/
public class Main2 implements Runnable {
private static Connection conn;
private static Statement stmt;
public Main2 () throws Throwable {
conn=DriverManager.getConnection("jdbc:postgresql://localhost/tanida","tanida","tanida");
conn.setAutoCommit(false);
stmt=conn.createStatement();
}
public static void main(String[] args) throws Throwable {
Class.forName("org.postgresql.Driver");
for(int i=0;i<6;i++) {
new Thread(new Main2()).start();
}
}
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
try {
int i=0;
while(!Thread.currentThread().isInterrupted()) {
stmt.executeUpdate("begin");
// stmt.executeUpdate("lock table test");
stmt.executeUpdate("update test set t='test' where t='test2'");
stmt.executeUpdate("end");
i++;
if(i%5==0)
System.out.println(Thread.currentThread());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
--
--
TANIDA Yutaka <tanida @ sra.co.jp>
pgsql-jp メーリングリストの案内