ruby-on-railsdatabasepostgresqlcirclecicircleci-2.0

Rails: rake db:structure:load times out on CircleCI 2.0


Currently, rake db:schema:load is run to setup the database on CircleCI. In migrating from using schema.rb to structure.sql, the command has been updated to: rake db:structure:load.

Unfortunately, it appears to hang and does not return:

$ bin/rake db:structure:load --trace
** Invoke db:structure:load (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:structure:load
WARNING: terminal is not fully functional

 set_config 
------------

(1 row)

(END)rake aborted!
Interrupt:
<STACK TRACE>
bin/rake:9:in `<main>'
Tasks: TOP => db:structure:load
Too long with no output (exceeded 10m0s)

Found someone else with the same issue on CircleCI, no answers though.


Solution

  • This seems to have something to do with the psql client's output to the terminal expecting user input:

     set_config 
    ------------
    
    (1 row)
    
    (END)   <--- like from a terminal pager
    

    Not exactly a proper solution, but a workaround in .circleci/config.yml:

    jobs:
        build:
            docker:
              - image: MY_APP_IMAGE
                environment:
                  PAGER: cat # prevent psql commands using less