I’m getting a build error that is only happening when I run my build on travis. After a TON of debugging I have determined that Travis seems to be calling methods out of order. I don’t know how this could be possible but it is what I’m observing in my output.
The order that things should happen is 1) call delete method 2) call the method that lists “Missing Debtors” and also imports data. There is a unique constraint on my table such that if the exact record already exists when imported it will throw an exception so it is important that the DELETE happens first.
So on my local machine my debugging output is correct and looks like this:
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
0
-------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------EXISTING RECORDS-----------------------------------------------------------
#<ActiveRecord::Relation []>
----------------------------------------------------------------------------------------------------------------------------------
[LIST OF 21 RECORDS THAT WILL BE IMPORTED]
----------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
21
-------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------EXISTING RECORDS-----------------------------------------------------------
#<ActiveRecord::Relation []>
----------------------------------------------------------------------------------------------------------------------------------
[LIST OF 21 RECORDS THAT WILL BE IMPORTED]
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
21
-------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------EXISTING RECORDS-----------------------------------------------------------
#<ActiveRecord::Relation []>
----------------------------------------------------------------------------------------------------------------------------------
[LIST OF 21 RECORDS THAT WILL BE IMPORTED]
Now what I’m seeing in the output from my build:
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
0
-------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------EXISTING RECORDS-----------------------------------------------------------
#<ActiveRecord::Relation []>
----------------------------------------------------------------------------------------------------------------------------------
[LIST OF 21 RECORDS THAT WILL BE IMPORTED]
----------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
21
-------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
0
-------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------EXISTING RECORDS-----------------------------------------------------------
#<ActiveRecord::Relation []>
----------------------------------------------------------------------------------------------------------------------------------
[LIST OF 21 RECORDS THAT WILL BE IMPORTED]
----------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------EXISTING RECORDS-----------------------------------------------------------
#<ActiveRecord::Relation [LIST OF 21 RECORDS THAT NEVER GOT DELETED]>
----------------------------------------------------------------------------------------------------------------------------------
[LIST OF 21 RECORDS THAT WILL BE IMPORTED]
----------------------------------------------------------------------------------------------------------------------------------
F HTML screenshot: XXXXXXXX (SCREENSHOT SHOWING ActiveRecord::RecordNotUnique EXCEPTION)
Image screenshot: XXXXXXXX
So if you look at the output from Travis you see this output:
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
21
-------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------NUMBER DELETED-----------------------------------------------------------
0
-------------------------------------------------------------------------------------------------------------------------------------
The delete method is being called twice, the second one is out of order, it shouldn’t get called here. It doesn’t delete anything and since it gets called out of order the previous data that was imported never gets deleted and then when the next import happens I get a rails error screen with a ActiveRecord::RecordNotUnique exception.
This seems like an issue in travis only as I am unable to reproduce it. Even if I open up a travis debugging session and ssh into it, run my build scripts, then run my tests they run without an error.
How could things be running out of order like this? I’m not running any concurrent processes. Has anyone encountered anything like this before?