1 year ago

#25875

test-img

Atul

H2 DB multipole connections in AWS EFS using AWS Lambda

I have been struggling to find a solution for below use case for H2 database

  1. I have an H2 db file

  2. This file has been kept in AWS EFS

  3. This is because two lambda functions can access this DB file concurrently. One lambda reads the file and other updates to this file

  4. I am facing below issue as -

  • The first lambda queries the H2 DB file and it creates a lock to it . The lock is in EFS file system
  • When second lambda tries to update the same H2 DB file , it finds a lock on the file and it says "Caused by: java.lang.IllegalStateException: The file is locked: nio:/file.mv.db [1.4.192/7]"

I have searched a lot on internet and this link H2 Database multiple connections relates same to my use case

I have used same approach and used below connection URL with AUTO_SERVER=TRUE.

But I am still facing same issue .

Can anybody help here please ?

Below are connections URLs I tried :

  jdbc:h2:file/mnt/efs/dbfile;AUTOCOMMIT=ON;LOG=0;CACHE_SIZE=65536;AUTO_SERVER=TRUE
  
  jdbc:h2:/mnt/efs/dbfile;AUTOCOMMIT=ON;LOG=0;CACHE_SIZE=65536;AUTO_SERVER=TRUE

aws-lambda

amazon-efs

h2db

0 Answers

Your Answer

Accepted video resources