Using Isolation Level Serialazable
I use Visual Basic/Windows Forms to create my project
I have my form for amending orders ready.
The flow is:
Get order number
Open connection
sqlcommand to check if order number exists
if not, return
Set isolation level serialazable
Get response to "Delete full order"
If response is "Yes":
trans = connlock.BeginTransaction("Delete_OA")
qry = "delete from ilprod where iorno1 = " & miorno1.Text
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
trans.Commit()
MessageBox.Show("OA " & miorno1.Text & "Deleted")
if response is no:
I display the order details and items.
if an item is selected, get response to "Delete item?"
if response is yes,
trans = connlock.BeginTransaction("Delete_Item")
qry = "delete from ilprod where csno = " & mcsno.Text & " and itno = " & mitno.Text
Dim cmd As SqlCommand
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
miorno1.Text = 0
MessageBox.Show("Item " & miorno1.Text & "/" & mnitno.Text & "Deleted")
trans.Commit()
and continue amendment.
if response is no: proceed to amend item details etc.
Finally, save amendments:
qry = "select opamno from opcsno"
Dim cmd = New SqlCommand(qry, connlock, trans)
new_amno.Text = cmd.ExecuteScalar() + 1
qry = "update opcsno set opamno = opamno + 1"
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
qry = "update opmain set "
qry = qry & "DORNO= " & "'" & DORNOTextBox.Text & "'"
qry = qry & ",DORDT = " & "'" & CDate(DORDTDateTimePicker.Value) & "'"
qry = qry & ",SIP1FL = " & SIP1FLTextBox.Text
qry = qry & ",SIP2FL = " & SIP2FLTextBox.Text
qry = qry & ",SIP3FL = " & SIP3FLTextBox.Text
qry = qry & ",STAXFL = " & STAXFLCOMBO.SelectedValue
qry = qry & ",DESTFL = " & DESTFLCOMBO.Text
qry = qry & ",MODEFL = " & MODEFLCOMBO.SelectedValue
qry = qry & ",CARRFL = " & CARRFLCOMBO.SelectedValue
qry = qry & ",PACKFL = " & PACKFL.SelectedValue
qry = qry & ",PAYTFL = " & PAYTFLCOMBO.SelectedValue
qry = qry & ",SCDLFL = 4"
qry = qry & ",AMNO = " & new_amno.Text
qry = qry & ",IRDT = " & "'" & CDate(IRDTDateTimePicker.Value) & "'"
qry = qry & " WHERE csno = " & mcsno.Text & ""
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
qry = " delete from opnarr where csno = " & mcsno.Text
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
If vbTrue Then
qry = "insert into opnarr (csno,narfl,narr,amno) values ("
qry = qry & mcsno.Text & ","
qry = qry & "'A',"
qry = qry & "'" & PAYTFLCOMBO.Text & "'" & ","
qry = qry & new_amno.Text & ")"
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
End If
If vbTrue Then
qry = "insert into opnarr (csno,narfl,narr,amno) values ("
qry = qry & mcsno.Text & ","
qry = qry & "'D'" & ","
qry = qry & "'" & STAXFLCOMBO.Text & "'" & ","
qry = qry & new_amno.Text & ")"
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
End If
If mmcd = "Z998" Or mmcd = "Z999" Then
qry = "insert into opnarr (csno,narfl,narr,amno) values ("
qry = qry & mcsno.Text & ","
qry = qry & "'X'" & ","
qry = qry & "'" & mname.Text & "'" & ","
qry = qry & new_amno.Text & ")"
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
End If
For Each row In DataGridView1.Rows
If row.selected Then
qry = "update ilprod set qlty = " & row.cells("qlty").value
qry = qry & ",siz1 = " & row.cells("siz1").value & ",siz2 = " & row.cells("siz2").value & ",siz3 = " & row.cells("siz3").value & ",sppr = " & "'" & row.cells("sppr").value & "'"
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
qry = "update ilprod set pqty = 0, pmtr = 0 where csno = " & mcsno.Text & " and itno = " & mitno.Text & " and pqty < 0"
' This means that qnty will not be equal to inqty+pqty in such records
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
qry = "delete from opscdl " & "where csno = " & mcsno.Text & " and itno = " & mitno.Text
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
For Each scdlrow In DataGridView2.Rows
If scdlrow.cells("csno").value = mcsno.Text And scdlrow.cells("itno").value = mitno.Text And scdlrow.cells("sqnty").value <> 0 Then
qry = "insert into opscdl (csno,itno,sqnty,srmtr,sdate,stype,amno) values (" & scdlrow.cells("csno").value & "," & scdlrow.cells("itno").value & "," & scdlrow.cells("sqnty").value & "," & scdlrow.cells("srmtr").value & "," & "Convert(date,'" & scdlrow.cells("sdate").value & "')" & "," & "'" & scdlrow.cells("stype").value & "'" & "," & new_amno.Text & ")"
cmd = New SqlCommand(qry, connlock, trans)
cmd.ExecuteNonQuery()
End If
Next
End If
Next
trans.Commit()
When I run the form, the Order is amended successfully: but I do not think the isolation level is set correctly: as I can access the order from another (new query) connection when the amendment is going on and not yet saved
There are a large number of commands between accesing the records from SQL and the above Save Commands.
Can Can someone guide me?
To repeat: the flow is
SET ISOLATION LEVEL
GET ORDER NUMBER FROM SCREEN
DELETE ORDER?
DELETE ITEM?
AMEND OA AND SAVE AMENDMENTS
I apologise if the above has been unclear.
Mohan
MohanSQL
Hi Mohan,
As the issue is more related to Visual Basic/Windows Forms programming, I would like to recommend you post the question in the
Visual Basic forum or
Windows Forms forum. It is appropriate and more experts will assist you.
Also, you can check the following articles about starting database transactions with the specified isolation level in Visual Basic or other projects.
SqlConnection.BeginTransaction Method (IsolationLevel)
http://msdn.microsoft.com/en-us/library/5ha4240h(v=vs.110).aspx
ADO.NET Transactions and Concurrency in VB.NET
http://www.dotnetheaven.com/article/ado.net-transactions-and-concurrency-in-vb.net
Thanks,
Lydia Zhang
Similar Messages
-
Problems in using isolation level serializable
Dear everyone:
This is the problem I met while using isolation level
serializable in ORALCE 8.0.3 for Netware:
Program 1 Program2
Insert record 1 into table 1
select record 1 from table1
commit
select record1 from table1
insert record 2 into table1
select record2 from table1
commit
select record2 from table1
update record2 from table1
commit
delete record2 from table1
commit
update record1 from table1
*ORA-8177 cannot serialize
access for this transaction
According to my understanding to the serialization isolation
level, it should not occurs.
Anyone can give me some ideas?
Regards!
nullDear everyone:
This is the problem I met while using isolation level
serializable in ORALCE 8.0.3 for Netware:
Program 1 Program2
Insert record 1 into table 1
select record 1 from table1
commit
select record1 from table1
insert record 2 into table1
select record2 from table1
commit
select record2 from table1
update record2 from table1
commit
delete record2 from table1
commit
update record1 from table1
*ORA-8177 cannot serialize
access for this transaction
According to my understanding to the serialization isolation
level, it should not occurs.
Anyone can give me some ideas?
Regards!
null -
Setting isolation level to 2.
Hi All,
I'm trying to use Isolation level 2 for "read committed" isolation.
all I can find is how to set level 3 isolation (by calling setTxnSerializableIsolation(true)).
Thanks for your help.
~avironHi Aviron,
The isolation degrees are discussed in the TXN GSG guide here (chapter 4. Concurrency, Isolation):
http://www.oracle.com/technology/documentation/berkeley-db/je/TransactionGettingStarted/BerkeleyDB-JE-Txn.pdf
For configuring committed reads (degree 2 isolation), you can do one of the following:
- create your transaction (txn) so that it allows committed reads, by specifying true for the TransactionConfig.setReadCommitted() call;
- specify true on the CursorConfig.setReadCommitted() call;
- specify LockMode.READ_COMMITTED to configure degree 2 isolation on a read-by-read basis.
Regards,
Andrei -
Query Connection Isolation Levels
I can do SA_CONN_LOCKS and get the information of all the connections. I have all the connection numbers.
I then need a way to determine the ISOLATION LEVEL of each of the connections. We use a different ISOLATION LEVEL and we want to make sure that isolation level is proper for all connections to stop freezing.
I'm sure I can get the isolation level of the current connection (ITSELF) ---
1. How do I get the isolation level of my own connection?
2. How do I get the isolation levels of all the other connections? (If I have to do it manually for each connection, that's not an issue for me)
Please help!
We are setting an EXECLUSIVE lock on a table which is causing all the other workstations to freeze, and I'm sure that we are setting the isolation level to stop this from happening when opening all the connections - so for some reason, something is getting set back or the user is creating other custom connections and locking records.
Thank you.
Sybase SQL Anywhere 12.01Hi Robert,
I have logged the incident with support. We haven't move much towards resolution on that side, but we have on our side.
If you're ever finding that an incident needs more attention to it or that you are not receiving an urgent reply from SAP, there is a mechanism to have the SAP Customer Interaction Center involved and for the incident to be flagged at higher support levels, if the production situation warrants it - see: https://websmp106.sap-ag.de/call1sap
The query runs just fine! It runs in 3 seconds.
If we put those two lines back - the query freezes and can sit there forever.
On the surface, this doesn't sound like a locking issue, but more of a performance issue with those views/tables. Especially if you are using isolation level 0.
They asked us to do logging (your SAP SUPPORT) and we did ..... we gave it to them and they came back and told us it could have to do with some known bug called "Issue with parallelism and we can test this by setting the max_query_tasks to 1"
Yes, after reviewing the incident I can see that we have requested and you have performed and provided us with some request logging, and after reviewing this information we had found that there were large table scans inside queries with intra-query parallelism involved (indicating a performance issue). To diagnose the performance issue further, we have requested graphical plans with statistics from these queries to see in more detail about why we are picking the query plans we are at that time. The optimizer uses statistical analysis to pick plans so therefore we need to understand the statistics behind its decisions.
The above suggestion was provided as an interim diagnostic test in order to determine if the behaviour is related to known fixed issues related to intra-query parallelism on earlier builds of 12.0.1. Providing the specific build number of 12.0.1 would avoid needing to run the diagnostic test.
However, if you are convinced that locking is truly the root issue of your problem, please provide the full output of sa_locks() at this time - there should be 11 columns, including the 'lock_type' information which would provide the type of object that is being locked:
conn_name,conn_id,user_id,table_type,creator,table_name,index_id,lock_class,lock_duration,lock_type,row_identifier
If you are over 1000 locks, you will need to increase the 'max_locks' argument to sa_locks().
I have also noted that you have also just provided a response to us in the incident shortly after posting here. Please continue to use the support incident to work with us directly for the diagnostic discussion and your resolution options.
Regards,
Jeff Albion
SAP Active Global Support -
Isolation level when using UserTransaction
What isolation level does WLS assign to JDBC connection objects when used within
a user-controlled JTA transaction?
e.g. when using the following code within a servlet:
UserTransaction ut = (UserTransaction) ictx.lookup("java:comp/Usertransaction");
ut.begin();
DataSource ds = ictx.lookup("java:comp/env/jdbc/datasource");
Connection conn = ds.getConnection();
ResultSet rs = ps.executeQuery("....");
conn.commit();
Does weblogic force a specific isolation level, or will it fall back to the default
of the database?
We are using WLS 8.1 SP1 and Oracle 9.
/Johan
johan Eltes wrote:
> What isolation level does WLS assign to JDBC connection objects when used within
> a user-controlled JTA transaction?
> e.g. when using the following code within a servlet:
>
> UserTransaction ut = (UserTransaction) ictx.lookup("java:comp/Usertransaction");
> ut.begin();
> DataSource ds = ictx.lookup("java:comp/env/jdbc/datasource");
> Connection conn = ds.getConnection();
> ...
> ResultSet rs = ps.executeQuery("....");
> ...
> conn.commit();
>
> Does weblogic force a specific isolation level, or will it fall back to the default
> of the database?
> We are using WLS 8.1 SP1 and Oracle 9.
The Spec says that the connection should be in the DBMS's default isolation level
until set differently. For Oracle you will be in READ-COMMITTED. That's what you want
because Oracle's SERIALIZABLE isolation level is problematic, not doing what most
folks assume...
Joe
> /Johan
-
Crrystal Reports using ADO. How do you Change the Isolation Level?
Post Author: jmetaxas
CA Forum: Data Connectivity and SQL
Crrystal Reports using ADO. How do you Change the Isolation Level? I found a knowledge base article that allows you to change it for ODBC. But nothing on ADO. I kicked around changing the reports to ODBC but even then the keys described in the article do no exist. Any suggestions?
Thanks,
John MetaxasT-Bob wrote:
I want to make sure that points 2&3 are at the same level, so I can just move the envelope region between them up and down to change the volume. Any quick way to do this to speed up my process?
Specifically to address this point: if you mouse over the audio levels' rubber band segment BETWEEN your points 2) and 3) until the cursor changes to an up/down adjustment arrow ⬍, and move it up/down, it will adjust BOTH the levels at 2) and 3), maintaining the relative difference between them (or, if points 2) and 3) start at the same level, this adjustment will keep them equal as you drag them both up/down together in one action.)
As usual, much easier to DO it, rather than describe it! -
hi,
--DBCC FREEPROCCACHE
--DBCC DROPCLEANBUFFERS
CREATE TABLE #temp(ID BIGINT NOT NULL)
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
BEGIN TRAN
INSERT INTO #temp (id) SELECT wid FROM w WHERE ss=1
UPDATE w SET ss =0 WHERE wid IN (SELECT id FROM #Temp)
COMMIT TRAN
IF (EXISTS(SELECT * FROM #temp))
BEGIN
SELECT 'P'
SET TRANSACTION ISOLATION LEVEL SNAPSHOT
BEGIN TRAN
insert into a ( a,b,c)
SELECT a , b ,c FROM w WHERE wid= 104300001201746884
COMMIT TRAN
END
Q1) changin isolation in this way is correct or not?
Q2) why i have chainged isolation is , because
this stmt was updated by other trnsaction also, and i also wanted to udpate it , so i made one repetable read and then snapshot.
UPDATE w SET ss=0 WHERE wid IN (SELECT id FROM #Temp)
DROP TABLE #temp
yours sincerleyhttp://blogs.msdn.com/b/craigfr/archive/2007/05/16/serializable-vs-snapshot-isolation-level.aspx
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Hello,
I'm new to the Oracle environment and have just started using PL/SQL on Oracle 8i. Where can I find info on how Oracle locks data and how transaction isolation levels are used? We've still not recvd our manuals so please any replies referring to manuals are not welcome!You could move forward balance into its own table. That was, the SELECT will not lock on the original table. Most of the running balance schemes that I have seen take a snapshot as of a given date (say, statement printing date) and record both the timestamp and the amount. Next month, you simply get last month's vaule and timestamp and query on transactions after that timestamp.
- Saish -
Can you set isolation levels of message-driven bean transactions?
The problem: I have 3 different message-driven beans which each get a different type of message, except for a field that is common to all. That field is used as the primary key of an entity object. The message-driven beans configured to use a container managed transaction. Each message-driven bean, in processing the message, first does a lookup by primary key to see if the object associated with the key exists, and if it does not, it requests the entity's home object to create it. After that, they do further processing. The problem is that sometimes all the beans simultaneously get a message, resulting in each bean checking for the entity object at about the same time, and if they fail to find it (because none of them has created it yet), each creates an object, all with the same primary key. This is not caught until the beans start to complete their onMessage method, which I believe results in the container committing the transaction. One of the transactions will be committed successfully, while the other two will fail, get rolled back, and then be retried with the same message. The second time through, the other beans will find the entity object (since it has been created and committed) and they will complete correctly. In the end, they right thing occurs, except that there is a troubling exception or 2 in the log telling about the constraint violation (with the primary key) and the rollback. If it was just me, that would be fine, but our customer does not like to see exceptions in the log; that indicates to him that something is wrong.
So, I am looking for someway to make sure that the actions of the message-driven beans are serialized. One suggestion from a colleague was to set the isolation level of the transactions being used by the container in processing the message-driven beans' onMessage method. However, the documentation does not mention any way to do this for a message-driven bean. Suggestions?
Is the use of a UserTransaction a better way to do this? If I acquire a UserTransaction within the onMessage method of a message-driven bean, can I set its isolation level? How would this work? When I get a UserTransaction, does each client get a different transaction, or do they all get the same one?(1) The WebLogic JMS "unit-of-order" feature is a heavily adopted feature that was specifically designed to handle similar use cases - see the JMS developer guide for extensive documentation. In your use case, if "key" is used to define UOO, then there's no limit on the number of keys that can be processed concurrently, but messages for any particular key will be processed single-threaded in the order in which they were first submitted.
Note that if you're using distributed destinations, the UOO feature is still fully supported - but the developer and/or administrator needs to decide whether to configure the destination to use "hash" or "path service" based routing (the JMS UOO edoc outlines the trade-offs).
(2) Another alternative is to use a single MDB with max-beans-free-pool that processes all three types (as the other poster suggested). I think this assumes all MDBs run on the same JVM.
(3) Another alternative is to use multiple queues, with a single MDB on each Q. Where some sort of hash algorithm is used to determine which Q is for the key. This approach is a "hand-coded" variant of the approach in (1) with "hash" based routing enabled...
(4) If all MDBs actually do run in the same JVM, a third alternative is to use code the application to use a common lock to protect each key, eg, something like:
// assume MyLock is simply a class with a "reference counter"
// assume some global "staticHM" hash map that is all MDBs can access
onMessage() {
MyLock lock = null;
key= msg.getKey();
synchronized(staticHM) {
lock = staticHM.get();
if (lock = null) {
lock = new lock();
staticHM.put(key, new lock());
lock.incRefCount();
try {
synchronized(lock) {
// only one onMessage will be able to lock a particular key at a time
do your work;
} finally {
synchronized(staticHT) {
if (lock.defRefCount() == 0) staticHM.remove(lock);
if (lock = null) staticHM.put(key);
If multiple threads get a message with the same key, then only one thread at a time will work on the key.
Hope this helps,
Tom -
Hi,
In mssql i am using following things.
I have two database D1 and D2, i am using snapshot isolation (ALTER DATABASE MyDatabase
SET ALLOW_SNAPSHOT_ISOLATION ON) in both database.
Following is the situation.
1) There is one SP sp1 ( it can be in any database d1 or d2), it updates d2 from d1.
2) d2 is used for reading by web, execept above SP sp1
3) d1 gets updation from web in readcommite isolation.
4) both database will be on same instence of mssql.
Q1) wanted to know how to implement the same thing in oracle 11x express edition.
Q2) is there any diffrence between snapshot isolation level of mssql and oracel.
any link would be help full.
yours sincerely>Q1) should i set the option to OFF after the process(ts) is complete
No keep it on.
>Q2) ALLOW_SNAPSHOT_ISOLATION ON , will affect other isolation level's transactions
No it will not affect any other transaction isolation level.
>Q3) is my choice of isolation level for process(ts) is correct or there can be any other solution.
Seems fine, although there are probably many other solutions.
David
David http://blogs.msdn.com/b/dbrowne/ -
How do you determine a process or sessions isolation level.
We are using COM+ components to issue database statements against an Oracle 8i database. COM+ has a property that allows you to set the isolation level. Is there any tool or query that would allow me to verify the isolation level in use by a session or process? I want to verify this property is actually affecting the connection to the DB.
Thanks,
SamFLAG is just one of those columns that Oracle uses. It isn't documented but, as far as I know (which isn't very far), the only use for it is to record the isolation level for the transaction.
I didn't mention it because I didn't think it helped you, for this reason: we don't get a record in the v$transaction view until the transaction has already started. At which point it is too late to change the ISOLATION_LEVEL for the transaction.
Although I suppose you could do this:
BEGIN
UPDATE dummy_table set col1 = col1;
-- remember V$TRANSACTION shows all txns
SELECT count(1) INTO ln
FROM v$transaction t, v$session s
WHERE bitand(t.flag,268435456) <> 0
AND s.taddr = t.addr
AND s.audsid = sys_context('userenv', 'sessionid');
IF ln = 0
THEN
ROLLBACK;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
END IF;
-- do_whatever
COMMIT;
END ;.
Cheers, APC -
Bug in Oracle's handling of transaction isolation levels?
Hello,
I think there is a bug in Oracle 9i database related to serializable transaction isolation level.
Here is the information about the server:
Operating System: Microsoft Windows 2000 Server Version 5.0.2195 Service Pack 2 Build 2195
System type: Single CPU x86 Family 6 Model 8 Stepping 10 GenuineIntel ~866 MHz
BIOS-Version: Award Medallion BIOS v6.0
Locale: German
Here is my information about the client computer:
Operaing system: Microsoft Windows XP
System type: IBM ThinkPad
Language for DB access: Java
Database information:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
The database has been set up using the default settings and nothing has been changed.
To reproduce the bug, follow these steps:
1. Create a user in 9i database called 'kaon' with password 'kaon'
2. Using SQL Worksheet create the following table:
CREATE TABLE OIModel (
modelID int NOT NULL,
logicalURI varchar (255) NOT NULL,
CONSTRAINT pk_OIModel PRIMARY KEY (modelID),
CONSTRAINT logicalURI_OIModel UNIQUE (logicalURI)
3. Run the following program:
package test;
import java.sql.*;
public class Test {
public static void main(String[] args) throws Exception {
java.util.Locale.setDefault(java.util.Locale.US);
Class.forName("oracle.jdbc.OracleDriver");
Connection connection=DriverManager.getConnection("jdbc:oracle:thin:@schlange:1521:ORCL","kaon","kaon");
DatabaseMetaData dmd=connection.getMetaData();
System.out.println("Product version:");
System.out.println(dmd.getDatabaseProductVersion());
System.out.println();
connection.setAutoCommit(false);
connection.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
int batches=0;
int counter=2000;
for (int outer=0;outer<50;outer++) {
for (int i=0;i<200;i++) {
executeUpdate(connection,"INSERT INTO OIModel (modelID,logicalURI) VALUES ("+counter+",'start"+counter+"')");
executeUpdate(connection,"UPDATE OIModel SET logicalURI='next"+counter+"' WHERE modelID="+counter);
counter++;
connection.commit();
System.out.println("Batch "+batches+" done");
batches++;
protected static void executeUpdate(Connection conn,String sql) throws Exception {
Statement s=conn.createStatement();
try {
int result=s.executeUpdate(sql);
if (result!=1)
throw new Exception("Should update one row, but updated "+result+" rows, query is "+sql);
finally {
s.close();
The program prints the following output:
Product version:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
Batch 0 done
Batch 1 done
java.lang.Exception: Should update one row, but updated 0 rows, query is UPDATE OIModel SET logicalURI='next2571' WHERE modelID=2571
at test.Test.executeUpdate(Test.java:35)
at test.Test.main(Test.java:22)
That is, after several iterations, the executeUpdate() method returns 0, rather than 1. This is clearly an error.
4. Leave the database as is. Replace the line
int counter=2000;
with line
int counter=4000;
and restart the program. The following output is generated:
Product version:
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.1.0 - Production
Batch 0 done
Batch 1 done
java.sql.SQLException: ORA-08177: can't serialize access for this transaction
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:796)
at test.Test.executeUpdate(Test.java:33)
at test.Test.main(Test.java:22)
This is clearly an error - only one transaction is being active at the time, so there is no need for serialization of transactions.
5. You can restart the program as many times you wish (by chaging the initial counter value first). The same error (can't serialize access for this transaction) will be generated.
6. The error doesn't occur if the transaction isolation level isn't changed.
7. The error doesn't occur if the UPDATE statement is commented out.
Sincerely yours
Boris MotikI have a similar problem
I'm using Oracle and serializable isolation level.
Transaction inserts 4000 objects and then updates about 1000 of these objects.
Transactions sees inserted objects but cant update them (row not found or can't serialize access for this transaction are thrown).
On 3 tries for this transaction 1 succeds and 2 fails with one of above errors.
No other transactions run concurently.
In read commited isolation error doesn't arise.
I'm using plain JDBC.
Similar or even much bigger serializable transaction works perfectly on the same database as plsql procedure.
I've tried oci and thin (Oracle) drivers and oranxo demo (i-net) driver.
And this problems arises on all of this drivers.
This problem confused me so much :(.
Maby one of Oracle users, developers nows cause of this strange behaviour.
Thanx for all answers. -
Setting isolation level with JDriver for Oracle/XA
edocs (http://e-docs.bea.com/wls/docs70/oracle/trxjdbcx.html#1080746) states that,
if using jDriver for Oracle/XA you can not set the transaction isolation level
for a transaction and that 'Transactions use the transaction isolation level set
on the connection or the default transaction isolation level for the database'.
Does this mean that you shouldn't try to set it programatically (fair enough)
or that you can't set it in the weblogic deployment descriptor either? Also anybody
got any idea what the default is likely to be if you are using an Oracle 9iR2
database? Is this determined by some database setting?IJ wrote:
edocs (http://e-docs.bea.com/wls/docs70/oracle/trxjdbcx.html#1080746) states that,
if using jDriver for Oracle/XA you can not set the transaction isolation level
for a transaction and that 'Transactions use the transaction isolation level set
on the connection or the default transaction isolation level for the database'.
Does this mean that you shouldn't try to set it programatically (fair enough)
or that you can't set it in the weblogic deployment descriptor either? Also anybody
got any idea what the default is likely to be if you are using an Oracle 9iR2
database? Is this determined by some database setting?The system should honor the setting defined in the deployment descriptor,
however, for oracle it may not be helpful to change it. Oracle provides two
isolation levels. The default is always READ_COMMITTED. The other
setting is SERIALIZABLE, but this hurts performance, and is also problematic
in the way oracle implements it. For instance, even if you set SERIALIZABLE,
oracle will not lock read data. It will allow other transactions to read and/or
alter data trhat another ongoing SERIALIZABLE transaction has read. The
only way to really lock read data in oracle is to issue oracle-specific SQL in
your select: "SELECT ..... FOR UPDATE".
All in all, you should collect a strong case for why you can't proceed with
READ_COMMITTED first. Then you should research oracle's recommendations
(and their problem record) with SERIALIZABLE.
Joe Weinstein at BEA -
Hi,
Im using Kodo 3.0.0 on Oracle 8.1.7.
I tried to define the isolation level in the kodo.properties:
e.g.: kodo.jdbc.TransactionIsolation: serializable
Unfortunately Oracle throws an exception which says, that "set
transaction" has to be the first statement called within a transaction. I
get this exception on almost every db access.
java.sql.SQLException: ORA-01453: SET TRANSACTION muss erste Anweisung der
Transaktion sein
at
kodo.jdbc.sql.SQLExceptions.getFatalDataStore(SQLExceptions.java:42)
at
kodo.jdbc.sql.SQLExceptions.getFatalDataStore(SQLExceptions.java:24)
at
kodo.jdbc.schema.LazySchemaFactory.findTable(LazySchemaFactory.java:1
50)
at
kodo.jdbc.meta.VerticalClassMapping.fromMappingInfo(VerticalClassMapp
ing.java:135)
at
kodo.jdbc.meta.RuntimeMappingProvider.getMapping(RuntimeMappingProvid
er.java:56)
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository
java:342)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:29
7)
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository
java:325)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:29
7)
at
kodo.jdbc.meta.MappingRepository.getMappings(MappingRepository.java:2
72)
at
kodo.jdbc.meta.MappingRepository.getMetaDatas(MappingRepository.java:
256)
at kodo.query.AbstractQuery.internalCompile(AbstractQuery.java:538)
at kodo.query.AbstractQuery.compile(AbstractQuery.java:502)
at kodo.datacache.CacheAwareQuery.compile(CacheAwareQuery.java:265)
-- WolfgangMarc,
Here you go...
kodo.util.FatalDataStoreException: ORA-01453: SET TRANSACTION must be
first statement of transaction
at
kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:897)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:566)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction.initTestModel(AbstractConcurrentAction.java:290)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction$InitRunnable.run(AbstractConcurrentAction.java:212)
at
edu.sjsu.recon.util.ConcurrencyUtilities.executeSynchronized(ConcurrencyUtilities.java:20)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction.setup(AbstractConcurrentAction.java:75)
at
edu.sjsu.recon.execution.ServerExecutor.beforeExecute(ServerExecutor.java:27)
at
edu.sjsu.recon.execution.AbstractExecutor.execute(AbstractExecutor.java:43)
at
edu.sjsu.recon.execution.DefaultExecutionCoordinator.executeAction(DefaultExecutionCoordinator.java:25)
at
edu.sjsu.recon.server.handler.ExecutionRequestHandler.handleRequest(ExecutionRequestHandler.java:63)
at edu.sjsu.recon.server.RequestProcessor.run(RequestProcessor.java:90)
NestedThrowablesStackTrace:
kodo.util.DataStoreException: ORA-01453: SET TRANSACTION must be first
statement of transaction
at
kodo.jdbc.sql.DBDictionary.newDataStoreException(DBDictionary.java:3004)
at kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:77)
at kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:63)
at kodo.jdbc.sql.SQLExceptions.getDataStore(SQLExceptions.java:43)
at kodo.jdbc.runtime.JDBCStoreManager.connect(JDBCStoreManager.java:871)
at
kodo.jdbc.runtime.JDBCStoreManager.retainConnection(JDBCStoreManager.java:189)
at kodo.jdbc.runtime.JDBCStoreManager.begin(JDBCStoreManager.java:114)
at
kodo.runtime.DelegatingStoreManager.begin(DelegatingStoreManager.java:95)
at
kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.java:1004)
at
kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:885)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:566)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction.initTestModel(AbstractConcurrentAction.java:290)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction$InitRunnable.run(AbstractConcurrentAction.java:212)
at
edu.sjsu.recon.util.ConcurrencyUtilities.executeSynchronized(ConcurrencyUtilities.java:20)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction.setup(AbstractConcurrentAction.java:75)
at
edu.sjsu.recon.execution.ServerExecutor.beforeExecute(ServerExecutor.java:27)
at
edu.sjsu.recon.execution.AbstractExecutor.execute(AbstractExecutor.java:43)
at
edu.sjsu.recon.execution.DefaultExecutionCoordinator.executeAction(DefaultExecutionCoordinator.java:25)
at
edu.sjsu.recon.server.handler.ExecutionRequestHandler.handleRequest(ExecutionRequestHandler.java:63)
at edu.sjsu.recon.server.RequestProcessor.run(RequestProcessor.java:90)
NestedThrowablesStackTrace:
java.sql.SQLException: ORA-01453: SET TRANSACTION must be first statement
of transaction
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:112)
at oracle.jdbc.driver.T4CStatement.execute_for_rows(T4CStatement.java:474)
at
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1028)
at oracle.jdbc.driver.OracleStatement.execute(OracleStatement.java:1516)
at
oracle.jdbc.driver.PhysicalConnection.setTransactionIsolation(PhysicalConnection.java:1412)
at
com.solarmetric.jdbc.DelegatingConnection.setTransactionIsolation(DelegatingConnection.java:266)
at
com.solarmetric.jdbc.DelegatingConnection.setTransactionIsolation(DelegatingConnection.java:266)
at
com.solarmetric.jdbc.DelegatingConnection.setTransactionIsolation(DelegatingConnection.java:266)
at
com.solarmetric.jdbc.DelegatingConnection.setTransactionIsolation(DelegatingConnection.java:266)
at
com.solarmetric.jdbc.ConfiguringConnectionDecorator.decorate(ConfiguringConnectionDecorator.java:93)
at
com.solarmetric.jdbc.DecoratingDataSource.decorate(DecoratingDataSource.java:90)
at
com.solarmetric.jdbc.DecoratingDataSource.getConnection(DecoratingDataSource.java:82)
at
com.solarmetric.jdbc.DelegatingDataSource.getConnection(DelegatingDataSource.java:131)
at
kodo.jdbc.schema.DataSourceFactory$DefaultsDataSource.getConnection(DataSourceFactory.java:305)
at
kodo.jdbc.runtime.JDBCStoreManager.connectInternal(JDBCStoreManager.java:887)
at kodo.jdbc.runtime.JDBCStoreManager.connect(JDBCStoreManager.java:865)
at
kodo.jdbc.runtime.JDBCStoreManager.retainConnection(JDBCStoreManager.java:189)
at kodo.jdbc.runtime.JDBCStoreManager.begin(JDBCStoreManager.java:114)
at
kodo.runtime.DelegatingStoreManager.begin(DelegatingStoreManager.java:95)
at
kodo.runtime.PersistenceManagerImpl.flushInternal(PersistenceManagerImpl.java:1004)
at
kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:885)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:566)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction.initTestModel(AbstractConcurrentAction.java:290)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction$InitRunnable.run(AbstractConcurrentAction.java:212)
at
edu.sjsu.recon.util.ConcurrencyUtilities.executeSynchronized(ConcurrencyUtilities.java:20)
at
edu.sjsu.recon.contribution.action.jdo.v10.kodo.v32.oracle.v101.simple.concurrency.AbstractConcurrentAction.setup(AbstractConcurrentAction.java:75)
at
edu.sjsu.recon.execution.ServerExecutor.beforeExecute(ServerExecutor.java:27)
at
edu.sjsu.recon.execution.AbstractExecutor.execute(AbstractExecutor.java:43)
at
edu.sjsu.recon.execution.DefaultExecutionCoordinator.executeAction(DefaultExecutionCoordinator.java:25)
at
edu.sjsu.recon.server.handler.ExecutionRequestHandler.handleRequest(ExecutionRequestHandler.java:63)
at edu.sjsu.recon.server.RequestProcessor.run(RequestProcessor.java:90)
Marc Prud'hommeaux wrote:
Cleo-
Can you post the complete stack (including all the nested stack traces)?
In article <[email protected]>, Cleo wrote:
Marc,
Here is the stack:
ORA-01453: SET TRANSACTION must be first statement of transaction
kodo.util.FatalDataStoreException
at
kodo.runtime.PersistenceManagerImpl.beforeCompletion(PersistenceManagerImpl.java:897)
at kodo.runtime.LocalManagedRuntime.commit(LocalManagedRuntime.java:69)
at
kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:566)
This is the code being executed:
Transaction initTransaction = initPersistenceManager.currentTransaction();
initTransaction.begin();
initPersistenceManager.makePersistentAll(model);
initTransaction.commit(); //EXCEPTION HERE
initPersistenceManager.close();
thx
Marc Prud'hommeaux wrote:
Cleo-
Can you post the complete stack trace from the exception? I expect it is
different from the one posted previously (which was with a much earlier
version of Kodo).
In article <[email protected]>, Cleo wrote:
Has anybody figured out how to solve this?
I am having the same problem with:
KODO 3.2
Oracle JDBC Dirver 10.1.0.3
thx
PS: (I am on a deadline for the end of this week)
Stephen Kim wrote:
First I would suggest using Kodo 3.0.1. Second I would suggest trying
to use 9.0.1 drivers which work very well with 8.1.7.
Wolfgang Hutya wrote:
Hi,
Im using Kodo 3.0.0 on Oracle 8.1.7.
I tried to define the isolation level in the kodo.properties:
e.g.: kodo.jdbc.TransactionIsolation: serializable
Unfortunately Oracle throws an exception which says, that "set
transaction" has to be the first statement called within a
transaction.
I
get this exception on almost every db access.
java.sql.SQLException: ORA-01453: SET TRANSACTION muss erste
Anweisung
der
Transaktion sein
at
kodo.jdbc.sql.SQLExceptions.getFatalDataStore(SQLExceptions.java:42)
at
kodo.jdbc.sql.SQLExceptions.getFatalDataStore(SQLExceptions.java:24)
at
kodo.jdbc.schema.LazySchemaFactory.findTable(LazySchemaFactory.java:1
50)
at
kodo.jdbc.meta.VerticalClassMapping.fromMappingInfo(VerticalClassMapp
ing.java:135)
at
kodo.jdbc.meta.RuntimeMappingProvider.getMapping(RuntimeMappingProvid
er.java:56)
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository
java:342)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:29
7)
at
kodo.jdbc.meta.MappingRepository.getMappingInternal(MappingRepository
java:325)
at
kodo.jdbc.meta.MappingRepository.getMapping(MappingRepository.java:29
7)
at
kodo.jdbc.meta.MappingRepository.getMappings(MappingRepository.java:2
72)
at
kodo.jdbc.meta.MappingRepository.getMetaDatas(MappingRepository.java:
256)
atkodo.query.AbstractQuery.internalCompile(AbstractQuery.java:538)
at kodo.query.AbstractQuery.compile(AbstractQuery.java:502)
atkodo.datacache.CacheAwareQuery.compile(CacheAwareQuery.java:265)
-- Wolfgang
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com
Marc Prud'hommeaux
SolarMetric Inc.
Marc Prud'hommeaux
SolarMetric Inc. -
Setting transaction isolation level in Weblogic 5.1
Hi,
I'm using Weblogic server5.1 and i'm trying to set the isolation level on one
of my session bean. Below is the code :
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>chargeMgr</ejb-name>
<jndi-name>chargeMgr</jndi-name>
<transaction-isolation>
<isolation-level>Serializable</isolation-level>
<method>
<ejb-name>chargeMgr</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
</transaction-isolation>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
I have checked the syntax against the weblogic documentation.
However, when i try to jar the beans up into the jar file (weblogic.ejbc), it
give me the following error :
org.xml.sax.SAXParseException: Element "weblogic-enterprise-bean" allows no further
input; "transaction-isolation" is not allowed.
Can anyone help?
Regards.
yes, only in weblogic-ejb-jar.xml , and you can see that from the DTD
source.
thanks
Yu
"cw lee" <[email protected]> wrote in message
news:[email protected]...
>
> thanks for ur advice.
>
> one thing i forgot to mention is that the isolation-level was specified in
weblogic-ejb-jar.xml.
> Do u mean that it must be placed in weblogic-cmp-rdbms-jar.xml and not
weblogic-ejb-jar.xml
> ?
>
> Are the codes u suggested to be in weblogic-ejb-jar.xml or
weblogic-cmp-rdbms-jar.xml
> ?
>
> Regards.
>
>
>
> "Yu Tian" <[email protected]> wrote:
> >the right name for Seriealizable should be: TRANSACTION_SERIALIZABLE.
> >so the
> >DD looks like:
> >
> ><?xml version="1.0"?>
> >
> ><!DOCTYPE weblogic-ejb-jar PUBLIC '-//BEA Systems, Inc.//DTD WebLogic
> >5.1.0
> >EJB//EN' 'http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd'>
> >
> ><weblogic-ejb-jar>
> > <weblogic-enterprise-bean>
> > <ejb-name>containerManaged</ejb-name>
> > <caching-descriptor>
> > <max-beans-in-cache>1000</max-beans-in-cache>
> > </caching-descriptor>
> > <persistence-descriptor>
> > <persistence-type>
> > <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
> > <type-version>5.1.0</type-version>
> > <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage>
> > </persistence-type>
> > <persistence-use>
> > <type-identifier>WebLogic_CMP_RDBMS</type-identifier>
> > <type-version>5.1.0</type-version>
> > </persistence-use>
> > </persistence-descriptor>
> > <jndi-name>containerManaged.AccountHome</jndi-name>
> > <transaction-isolation>
> > <isolation-level>TRANSACTION_SERIALIZABLE</isolation-level>
> > <method>
> > <ejb-name>containerManaged</ejb-name>
> > <method-name>*</method-name>
> > </method>
> > </transaction-isolation>
> > </weblogic-enterprise-bean>
> > </weblogic-ejb-jar>
> >
> >Thanks
> >
> >Yu
> >
> >
> >"cw lee" <[email protected]> wrote in message
> >news:[email protected]...
> >>
> >> Hi,
> >>
> >> I'm using Weblogic server5.1 and i'm trying to set the isolation level
> >on
> >one
> >> of my session bean. Below is the code :
> >>
> >> <weblogic-ejb-jar>
> >> <weblogic-enterprise-bean>
> >> <ejb-name>chargeMgr</ejb-name>
> >> <jndi-name>chargeMgr</jndi-name>
> >> <transaction-isolation>
> >> <isolation-level>Serializable</isolation-level>
> >> <method>
> >> <ejb-name>chargeMgr</ejb-name>
> >> <method-intf>Remote</method-intf>
> >> <method-name>*</method-name>
> >> </method>
> >> </transaction-isolation>
> >> </weblogic-enterprise-bean>
> >> </weblogic-ejb-jar>
> >>
> >> I have checked the syntax against the weblogic documentation.
> >> However, when i try to jar the beans up into the jar file
(weblogic.ejbc),
> >it
> >> give me the following error :
> >>
> >> org.xml.sax.SAXParseException: Element "weblogic-enterprise-bean"
allows
> >no further
> >> input; "transaction-isolation" is not allowed.
> >>
> >> Can anyone help?
> >>
> >> Regards.
> >>
> >
> >
>
Maybe you are looking for
-
I wish to sell my 2008 MacBook Pro. Have erased hard disk and when I went to fresh instal Mavericks OSX 10.6 (it gives me no other choice in the disk utility program) It says in the Apple Store, it is unavailable. But because this is done from disk u
-
Dear Expert, when i m running the test configuration in SECATT, i m getting the following error. "error when reading the file 'path' " i have chkd the file, i feel that file is ok as per my knowledge. what may b d solution ???? can anybody suggest. t
-
WF not sending the email notifications.
Hi DBAs, How and where to check whether Workflow Mailer account is locked or not. Thanks -Samar-
-
Accidentally Deleted iPhoto and now can't find on app store
Accidentally deleted my iPhoto app, and now I can't find it back on app store and not sure why. background info: china internet with VPN connection (LA server) china app store account is it because where i am? thanks for helping!
-
Hi, I am not able to connect to mail at home although I am not connect to internet via WIFI but every time I try to connect nokia mail, I got "Communication error Try again" error. I went to Nokia Priority for check up of my phone and tried Nokia ma