New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add explicit table locking #3964
Comments
What is a purpose of such lock?
|
@katzyn This lock provides fine grained table locking. What about I need to copy a file database not a memory one. And this DB can be rather big. If I lock whole database using |
I mean SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SNAPSHOT; Anyway, the fastest way to copy currently used persistent database is to use the |
@katzyn Thank you very much for your suggestions. But I need to copy from H2 to PostgreSQL. And I found only one way to do it - using JDBC connection. But other words I implement |
In that case use the mentioned |
@katzyn Ok. I will try. Thank you very much. |
But everything needs to be copied inside a single transaction to ensure consistency. |
@katzyn But if I have several tables with 10.000 ... rows won't be a buggy way to do in single transaction? I don't know what psql will do after insert(10 000) , insert(10 0000) + commit. Maybe it is better to lock whole h2 database using |
@katzyn Sorry, I messed different connections. It is time to sleep. I will try |
@katzyn I tested: I have two connections:
At Point X I connect to H2 database from IDE. At Point Y I try to do select in my IDE. It doesn't work. I see that connection is locked. So, with However, if istead of |
Why it should? It only provides you a consistent snapshot of your data, your transaction will not see changes from other transactions. |
PostgreSQL, Oracle and other RDBMS allow to lock tables explicitly in different modes. See https://www.postgresql.org/docs/current/sql-lock.html and https://docs.oracle.com/javadb/10.6.2.1/ref/rrefsqlj40506.html .
I suggest to add similar for H2. For example it can be used for copying whole database from H2 to PostgreSQL. There is a question on SO https://stackoverflow.com/questions/31390308/lock-table-with-exclusive-in-h2-database with 4k views that shows it is a rather popular feature.
The text was updated successfully, but these errors were encountered: