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
DATABASECHANGELOGLOCK
column LOCKGRANTED
does not use timezone
#2029
Comments
Hi @Marcono1234 Thanks for creating this issue. This may not be a simple change for existing users. We will add this to the list of issues that we are processing. |
➤ Wesley Willard commented: Given that changing the data type of the LOCKGRANTED column in the DATABASECHANGELOGLOCK table is not trivial, our best bet is to display the database server’s timezone information during listLocks. My initial research doesn’t show a database-agnostic way to do that, so how we do that looks like it will need to be different for each one. |
➤ Surya Aki commented: Please get the build from GH Actions |
➤ Erzsebet Carmean commented: Liquibase Core: LB2126/794/648e2a/202111-16 18:55+0000, b794 List-locks is not outputting the lockgranted time in the timezone of the database. I validated this by starting a Postgres docker instance with the timezone Africa/Lusaka. Docker Container Started with TimeZonedocker run --name pg_TZ_Africa -p5435:5432 -e POSTGRES_PASSWORD=password -e TZ=Africa/Lusaka postgres:12.6 I verify the timezone by running this query using psql: SELECT * FROM pg_timezone_names WHERE name = current_setting('TIMEZONE') The query result is:
---------------+--------+------------+-------- CREATE TABLE accounts ( BEGIN; INSERT INTO accounts(name,balance) #!/bin/sh while (true) --liquibase formatted sql --changeset liquibase:lb2126 postgres=# SELECT CURRENT_TIME;
|
@nvoxland, the linked pull request will only fix this issue for newly set up databases, right? That is fine for me as well, but I am just curious. I also mentioned the
Will this be addressed as well or should I open a new issue for that? |
I'll actually take the PR link off this issue because that PR is really just a work-around and not a real fix for this issue. Long-term we maybe should have the column type include the timezone when possible, but that will have to fall into the larger refactoring of the databasechangeloglock table we have planned. The #2217 only fixes up the locking SQL so it uses a NOW() function vs. a datetime string from the client so that at least we have a consistent time in the database regardless of how the client is configured. There is a similar issue with the databasechangelog table too, but the refactoring of that table will be after the databasechangeloglock logic, so it's probably worth holding off on creating the similar ticket for databasechangelog until we know for sure what we're doing with this ticket. |
Thanks a lot for the additional information. I am bit confused now that this issue was closed given that you said the PR is "not a real fix", but I assume this issue was closed intentionally? |
sorry @Marcono1234 you are right.. I closed this accidentally. Thanks for calling this out. I will re-open and but it back into the backlog so we still have this background when we start to look at more holistic improvements to databasechangeloglock table. |
Environment
Liquibase Version:
Latest (currently 48e1056)?
Liquibase Integration & Version: <Pick one: CLI, maven, gradle, spring boot, servlet, etc.>
Programmatic (?)
Liquibase Extension(s) & Version:
Database Vendor & Version:
PostgreSQL 13.3
(Docker container running on WSL)
Operating System Type & Version:
Windows 10
Description
It appears the
DATABASECHANGELOGLOCK
table has aLOCKGRANTED
column without timezone information.Therefore when one client acquires the lock, and afterwards a second client with a different timezone queries the lock, for example using
new Liquibase(...).listLocks()
, a wrong time will be reported byDatabaseChangeLogLock.getLockGranted()
.The reason for this is probably that here
datetime
is used, which is apparently mapped byDateTimeType
toTIMESTAMP
(without timezone information).In case you decide to change this, the documentation would have to be adjusted as well.
Maybe this affects columns of other tables as well, probably column
DATEEXECUTED
of tableDATABASECHANGELOG
.Steps To Reproduce
Actual Behavior
LOCKGRANTED
has no timezone information.Expected/Desired Behavior
LOCKGRANTED
should store timezone information.┆Issue is synchronized with this Jira Story by Unito
The text was updated successfully, but these errors were encountered: