--- "Christopher G. Stach II" <cgs (AT) ldsys (DOT) net>写道:
Quote:
Jack Wang wrote:
I hava done a test to use the MySQL XADataSource. For MySQL has no MYSQLXADataSourceFactory
class, so I coded one to produce MysqlXADataSource. MysqlXADataSource is configured in tomcat
5.5
server.xml. I can get the MysqlXADataSource instance xaDs by which I can get XAConnection and
XAResource. I also configured a UserTransaction which was produced by
org.objectweb.jotm.UserTransactionFactory. The following is the action's code in a test web
application. This action runs correctly the first time, but in the second time, it runs very
slow,
then reports "Lock wait timeout exceeded; try restarting transaction" error.
Is the XAConnection enlisted in the transaction? What does your innodb
status say? |
Thanks Christopher G. Stach II
Please ask how to enlist XAConnection in the transaction ? I did not enlist the XAConnection.
Maybe this is the reason. If so, how should I do ? The Innodb status is:
=========== begin ==================
mysql> show innodb status;
Quote:
Type | Name | Status
InnoDB | |
=====================================
|
060213 17:06:56 INNODB MONITOR OUTPUT
=====================================
Per second averages calculated from the last 3 seconds
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 3, signal count 3
Mutex spin waits 1, rounds 20, OS waits 0
RW-shared spins 6, OS waits 3; RW-excl spins 0, OS waits 0
------------
TRANSACTIONS
------------
Trx id counter 0 3843
Purge done for trx's n

< 0 3333 undo n

< 0 0
History list length 4
Total number of lock structs in row lock hash table 2
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 3841, not started, OS thread id 1436
MySQL thread id 2, query id 16 localhost 127.0.0.1 root
show innodb status
---TRANSACTION 0 3842, ACTIVE 145 sec, OS thread id 1004 starting index read
mysql tables in use 1, locked 1
LOCK WAIT 2 lock struct(s), heap size 320
MySQL thread id 3, query id 15 localhost 127.0.0.1 root Updating
update testdata set foo=888 where id=1
------- TRX HAS BEEN WAITING 145 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 50 n bits 72 index `PRIMARY` of table `test/test
data` trx id 0 3842 lock_mode X locks rec but not gap waiting
Record lock, heap no 2 PHYSICAL RECORD: n_fields 4; compact format; info bits 0
0: len 4; hex 80000001; asc ;; 1: len 6; hex 000000000f00; asc ;; 2:
len 7; hex 00000000340bf6; asc 4 ;; 3: len 4; hex 80000378; asc x;;
------------------
---TRANSACTION 0 3840, ACTIVE 295 sec, OS thread id 3452
2 lock struct(s), heap size 320, undo log entries 1
MySQL thread id 1, query id 7 localhost 127.0.0.1 root
--------
FILE I/O
--------
I/O thread 0 state: wait Windows aio (insert buffer thread)
I/O thread 1 state: wait Windows aio (log thread)
I/O thread 2 state: wait Windows aio (read thread)
I/O thread 3 state: wait Windows aio (write thread)
Pending normal aio reads: 0, aio writes: 0,
ibuf aio reads: 0, log i/o's: 0, sync i/o's: 0
Pending flushes (fsync) log: 0; buffer pool: 0
74 OS file reads, 9 OS file writes, 7 OS fsyncs
0.00 reads/s, 0 avg bytes/read, 0.00 writes/s, 0.00 fsyncs/s
-------------------------------------
INSERT BUFFER AND ADAPTIVE HASH INDEX
-------------------------------------
Ibuf for space 0: size 1, free list len 0, seg size 2, is empty
Ibuf for space 0: size 1, free list len 0, seg size 2,
0 inserts, 0 merged recs, 0 merges
Hash table size 116329, used cells 0, node heap has 0 buffer(s)
0.00 hash searches/s, 0.00 non-hash searches/s
---
LOG
---
Log sequence number 0 65229
Log flushed up to 0 65229
Last checkpoint at 0 65229
0 pending log writes, 0 pending chkp writes
10 log i/o's done, 0.00 log i/o's/second
----------------------
BUFFER POOL AND MEMORY
----------------------
Total memory allocated 37345384; in additional pool allocated 194432
Buffer pool size 1792
Free buffers 1728
Database pages 64
Modified db pages 0
Pending reads 0
Pending writes: LRU 0, flush list 0, single page 0
Pages read 64, created 0, written 3
0.00 reads/s, 0.00 creates/s, 0.00 writes/s
Buffer pool hit rate 1000 / 1000
--------------
ROW OPERATIONS
--------------
0 queries inside InnoDB, 0 queries in queue
1 read views open inside InnoDB
Main thread id 188, state: waiting for server activity
Number of rows inserted 0, updated 1, deleted 0, read 3
0.00 inserts/s, 0.00 updates/s, 0.00 deletes/s, 0.00 reads/s
----------------------------
END OF INNODB MONITOR OUTPUT
============================
-------------+
1 row in set, 1 warning (0.02 sec)
mysql>
============ end ===================
Quote:
--
Christopher G. Stach II
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=pi...ahoo (DOT) com |
p.s.
My environment is: win XP, Tomcat 5.5, MySQL 5.0, Connector/J 5.0.0 beta, JOTM 2.0.10.
When I run the following jsp ,it runs the first time, but has not updated the database's table
which has one record (id=1,foo=29 not 888) . And when I run it the second time, it is very slow,
and then reports error:
"- set rollback only (tx=bb14:38:0:016c028f7ae82ed0a2...99bc02

"
========= jsp begin =====================
<body bgcolor="#FFFFFF">
<%
UserTransaction ut = null;
try{
Context ctx = new InitialContext();
ut = (UserTransaction)ctx.lookup("java:comp/env/UserTransaction");
ut.begin();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/myDB");
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource xaDs =
(com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)c tx.lookup("java:comp/env/jdbc/myXADB");
XAConnection xCon = xaDs.getXAConnection();
javax.transaction.xa.XAResource xaRes = xCon.getXAResource();
Connection con = xCon.getConnection();
Statement stmt = con.createStatement();
String sql = "update testdata set foo=888 where id=1";
stmt.executeUpdate(sql);
ut.commit();
}catch(Exception e) {
e.printStackTrace();
try {
ut.rollback();
}catch(Exception e1){
System.out.println("[HelloWorldAction] rollback Error " + e1);
}
}
%>
</body>
========= jsp end========================
=========== resource begin =======================
<Resource name="jdbc/myXADB" auth="Container"
type="com.mysql.jdbc.jdbc2.optional.MysqlXADataSou rce"
factory="xa.MYSQLXADataSourceFactory"
driverClassName="com.mysql.jdbc.Driver"
databaseName="test"
serverName="localhost"
explicitUrl="true"
port="3306"
user="root"
password="password"
url="jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=utf-8"
/>
=========== resource end =======================
Wang Jun
__________________________________________________ _________
雅虎1G免费邮箱百分百防垃圾信
http://cn.mail.yahoo.com/
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=my...ie.nctu.edu.tw