Skip to content
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

Make lock granted time be consistent with date executed time. Modify listLocks message. LB-2126 #2217

Merged
merged 4 commits into from Jan 12, 2022

Conversation

wwillard7800
Copy link
Contributor

@wwillard7800 wwillard7800 commented Nov 16, 2021

Description

Changes all databases to use the database-based "now" SQL function rather than the client machine's now java code.

This makes it so that the times are always based on the database time and timezone vs. the more variable timezone and times of all the liquibase client machinese.

It also adds a note to the list-locks command to let users know how the date is computed.


Dev Handoff Notes (Internal Use)

Links

Testing

Test Requirements (Internal Liquibase QA)

Test using Postgres and MySQL.

Manual Tests

  • Verify update-sql uses the now() function to set the DATABASECHANGELOGLOCK.LOCKGRANTED value.
  • Verify list-locks shows the lock granted time in the database’s timezone (not client timezone).

Automated Tests

  • None required for this fix.

┆Issue is synchronized with this Jira Bug by Unito

@sync-by-unito
Copy link

sync-by-unito bot commented Jan 11, 2022

➤ Erzsebet Carmean commented:

Liquibase GitHub Build Tested: https://github.com/liquibase/liquibase/actions/runs/1468359672 ( https://github.com/liquibase/liquibase/actions/runs/1468359672|smart-link )

POSTGRES 12.6 (TZ Africa/Lusaka)

Verify update-sql outputs INERT INTO databasechangeloglock with LOCKGRANTED = NOW(); PASS

-- Lock Database
UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'LENOVO (172.18.240.1)', LOCKGRANTED = NOW() WHERE ID = 1 AND LOCKED = FALSE;Verify list-locks outputs lock granted time in the database’s time. PASS

Starting Liquibase at 15:10:30 (version [Core: LB-2126/794/648e2a/2021-11-16 18:55+0000, Pro: master/140/1edf3c/2021-11-16T16:02:23Z] #794 built at 2021-11-16 18:55+0000)
Liquibase Version: [Core: LB-2126/794/648e2a/2021-11-16 18:55+0000, Pro: master/140/1edf3c/2021-11-16T16:02:23Z]
Liquibase Pro [Core: LB-2126/794/648e2a/2021-11-16 18:55+0000, Pro: master/140/1edf3c/2021-11-16T16:02:23Z] by Liquibase licensed to customersuccess until Sun Jun 26 23:59:59 CDT 2022
Database change log locks for postgres@jdbc:postgresql://localhost:5435/postgres

  • LENOVO (172.18.240.1) at Jan 11, 2022 11:09:43 PM
    NOTE: The lock time displayed is based on the database's configured time
    Liquibase command 'list-locks' was executed successfully.
  • Client Time 15:10
  • Database Time 23:10

MySQL 5 (TZ +12:00)

Verify list-locks outputs lock granted time in database’s time. PASS

Starting Liquibase at 15:54:23 (version [Core: LB-2126/794/648e2a/2021-11-16 18:55+0000, Pro: master/140/1edf3c/2021-11-16T16:02:23Z] #794 built at 2021-11-16 18:55+0000)
Liquibase Version: [Core: LB-2126/794/648e2a/2021-11-16 18:55+0000, Pro: master/140/1edf3c/2021-11-16T16:02:23Z]
Liquibase Pro [Core: LB-2126/794/648e2a/2021-11-16 18:55+0000, Pro: master/140/1edf3c/2021-11-16T16:02:23Z] by Liquibase licensed to customersuccess until Sun Jun 26 23:59:59 CDT 2022
Database change log locks for testuser@172.17.0.1@jdbc:mysql://localhost:3306/testdb1?useSSL=false&allowPublicKeyRetrieval=true

  • LENOVO (172.18.240.1) at Jan 11, 2022 3:52:17 AM
    NOTE: The lock time displayed is based on the database's configured time
    Liquibase command 'list-locks' was executed successfully.
  • Client time 15:54
  • Database time 21:54

Additional Notes Regarding Extent of Fix

Liquibase list-locks sets the DATABASECHANGELOGLOCK.LOCKGRANTED = NOW(). This does result in list-locks displaying the database time IF the lock table was updated by a client session that did not override use of the database time zone in some manner. Please note that the timezone itself will not be displayed in the DATABASECHANGELOGLOCK.LOCKGRANTED column’s value. This fix addresses only the time/date of the insert Liquibase makes when a lock is created.

@suryaaki2 suryaaki2 merged commit f5a9b16 into master Jan 12, 2022
Conditioning++ automation moved this from Ready for Handoff (In JIRA) to Done Jan 12, 2022
@suryaaki2 suryaaki2 deleted the LB-2126 branch January 12, 2022 13:55
@nvoxland nvoxland removed this from Done in Conditioning++ Jan 21, 2022
@nvoxland nvoxland added this to the v4.7.1 milestone Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants