problem with caching of lock and changelog table existing


I Run Liquibase with postgresql, where for each schema a new instanceof Liquibase is created and run with a different default-schema-name and changelog file.

liquibase then creates a lock and changelog table in each schema - which is very good for me because the schemas should be completley independent of eachother.

Today I run into a problem, which I think did not happen before because I always build the single modules(each module has one db schema), and in the context of the tests, the db-schemas are created and liquibase is run a single time.

But when running liquibase multiple times on the same vm with different default-schemas, the JdbcDatabaseSnapshotGenerator instance, which is referenced from a static instance (and thus being shared by all instances of liquibase on the same VM), caches the hasDatabaseChangeLogTable and the hasDatabaseChangeLogLockTable values. So, even if for the actual schema there is no lock table or changelog file, liquibase is informed it does exist, which ofcause does not work right.

So - I removed this fields from JdbcDatabaseSnapshotGenerator -

I searched just a bit and think that the only call to the methods that cache these values are when initializing liquibase, and I ask myself if it make sense to cache them. Usually, liquibase will be instanciated once, and ran once, not ?  so there is no point in caching these values, because they are only used once, not? and if liquibase is run more than once, maybe it is better to check every time - as my settings show…

I am not sure, so I just wanted to ask (sorry for the long post) if I should commit the change ?

Cheers, Ron

Sorry, I must have missed this post initially.

Yes, commit the change you made, and I will take a look and modify it if necessary.  It is a performance optimization, but it may not be nessisary or a good idea, as you said.  Especially now that the tableExists check is much faster.