0

I have created a set of Liquibase scripts in a XML file. I have around 39 XML files like this. I am able to execute each of these XML files successfully.

However, I encountered a weird problem that when my WiFi is ON each XML file takes around 5 seconds to execute. When I turn it off, it takes less than a second to execute. So with WiFi ON it takes approx 240 seconds for all the XML files to complete. As you all will agree this is serious loss of productivity.

I dug deeper into this and found that in Liquibase code base there is a class called liquibase.lockservice.LockService. This class has a method acquireLock() which tries to update the database table DATABASECHANGELOGLOCK to acquire the lock.

The query I found was as follows:

UPDATE DATABASECHANGELOGLOCK SET LOCKED = TRUE, LOCKEDBY = 'fe80:0:0:0:9c31:10ff:fe88:4316%9 (fe80:0:0:0:9c31:10ff:fe88:4316%9)', LOCKGRANTED = '2015-11-06 16:33:06.54' WHERE ID = 1 AND LOCKED = FALSE

The execution of this piece of code is the root cause of so much time consumption.

Does someone knows why this must be happening?

My operating system is Mac Yosemite v10.10.5 (14F27). (Important: My colleagues who are on earlier version of Mac don't face this problem). My Java version is 1.7.0_79 and my maven version is Apache Maven 2.2.1 (r801777; 2009-08-06 15:16:01-0400)

Raj
  • 1,119
  • 4
  • 21
  • 41
  • Try to run this query from sql editor and I think that it should be fast. My guess is that fetching of ip address (that is passed to the query) could be slow, not the query itself. – dbf Nov 07 '15 at 20:47
  • Thank you dbf!. Can you please elaborate more on the fetching of IP address part? Or share some link so that I can read about them? – Raj Nov 08 '15 at 15:01
  • I dug more deeper into this and found that Liquibase has a class called liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator that created the query that I listed above. Also, it calls localHost.getHostName() & localHost.getHostAddress() to get LOCKEDBY column's value. And this is where most of the time are being spent. Now the question is why it spends so much time. – Raj Nov 08 '15 at 16:06
  • yes that's exactly what I mean - as I understand from http://stackoverflow.com/questions/28198365/rerverse-dns-lookups-on-windows-block-for-several-seconds-for-unresolvable-ip-ad it uses some network calls like DNS lookups etc for this method. So when you are working via WiFi it is possible that slow dns server is used, or DNS caching is disabled or something like this. So it is mostly a networking issue, not a java/liquibase. – dbf Nov 08 '15 at 16:59
  • Thanks for responding. What I did was to upgrade by Liquibase version from 2.0.5 to 3.4.1 and I saw that script runs very fast even on WIFI. However, some of the existing scripts are failing. I will be looking into that. But if this version helps then I am all set. – Raj Nov 08 '15 at 17:30
  • Looks like this change fixed your issue: https://github.com/liquibase/liquibase/commit/0172a2fc29db9e573cec5e09ed121c18c3e4e7f1 Before it it fetched hostname for every lock and now it is initialized only once. – dbf Nov 09 '15 at 06:27
  • Yep, when I debugged the code I found the same thing. It does make sense to have hostName populated once at class load. – Raj Nov 09 '15 at 15:54

0 Answers0