We are having an index on a table that results in error while deleting data from the table. The error says that it cannot find a row in the index. The following discussion we posted earlier has detailed explanation about it-
Discussion linkWe are trying to work around this problem by dropping the index and recreate it when the error occurs something like this-
try{
ACQUIRE DISK LOCK
{
try{
DELETE FROM TABLE WHERE ..... //this throws the index error that it cannot find the row in the index
}catch(Exception e){
try{
DROP INDEX
try{
RECREATE THE INDEX
}catch{
LOG RECREATE FAILURE
}
}catch{
LOG DROP FAILURE
}
finally{
RELEASE DISC LOCK
}
The problem we are facing is that the DROP is showing any error but while creating the index we are seeing the following error-
org.h2.jdbc.JdbcSQLException: Timeout trying to lock table "METRIC_DATA"; SQL statement:
create index timeseries.idx_metric_data_start_time on timeseries.metric_data(start_time) [50200-168]
We are not sure how H2 is handling locking on the tables internally. We are using the following parameters in the JDBC url-
CACHE_TYPE=LRU;PAGE_SIZE=16384;MVCC=TRUE;DB_CLOSE_DELAY=-1
Any help to resolve this is much appreciated.