Saturday, June 11, 2016

How to solve 'ISAM error: the file is locked' on Informix after using jdbc?

I have a Teacher/Sensei who teach me a lot the theory and principles of database engine really works his name is ++++++ a consultant and expert on Oracle, we worked together some months ago, my experience at that time was with Oracle Database 11g and Oracle Enterprise Manager, using some past knowledge I have to encourage a relative problem with Informix called "Dirty Reads" he explained to me that is a bad practice of consulting, updating or inserting data.

Informix is more sensible and treats data carefully based on ISAM which are algorithms in database in response a petition of users, so database principles are the same in other database engine, but on the other hand, at Oracle the engine resolves this problem internally and produce a problem or cost when it represents a problem causing interruptions in database, one of those is the best post I have introduced:

http://codefixes.blogspot.mx/2016/05/possible-solution-for-isam-error-key.html

When your process is concurrent and you have multiple users in the background pieces of data have to move on in the engine, if you do not measure and take the cost of queries that you are sending to database eventually you degrade the performance of your application, a problem could be at the next one:

 ISAM error: the file is locked (http://www.oninit.com/errorcode/index.php?pageid=-113)

For solving this kind of problems are two paths, one is correct the application (the better one) or give more time of waiting for the database (mitigating), so please check your query if you are doing an update of a bunch of elements you should go through the primary key o indexed fields, or in it is the case in a select check your where statement and modified to go to indexing field:

update table set column = :column1 where idprimarykey in (:idprimarykey);
select column1, column2, column3 from table where  idprimarykey in (:idprimarykey);

The other method is gained more time in transaction is not an effective way but informix provided:
...
> echo "set isolation to dirty read; select count(*) from customer;" | dbaccess stores_demo
... 
> echo "set lock mode to wait; select count(*) from customer;" | dbaccess stores_demo
...
http://www-01.ibm.com/support/docview.wss?uid=swg21508233

Dirty data are not welcomed to the database and you must carry the access to objects where are you doing transactions and service who are using it. 

Another important configuration when are using Informix is take care of Transaction Isolation and propagations after reading the documentation, Informix does not support readonly=true, and propagation must be in Serializable for betters ways, something like this if you are using spring framework:

@Transactional(value = "XXXXTransaccionManager", readOnly = false, propagation = Propagation.REQUIRED, timeout = 6000,isolation = Isolation.READ_COMMITTED)

And take care of using a version superior of 3 in the driver because it have some problems in the writing.


Best Regards, 

Important links:

No comments:

Post a Comment