Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add statement_timeout for postgres to avoid runaway queries

Cyril Rohr150751fca5a3
diff --git a/docker/setup/postinstall-common.sh b/docker/setup/postinstall-common.sh
index a047cb1abf6..fe11378d4d8 100755
--- a/docker/setup/postinstall-common.sh
+++ b/docker/setup/postinstall-common.sh
@@ -17,7 +17,7 @@ su - postgres -c "$PGBIN/pg_ctl -D /tmp/nulldb -l /dev/null -w start"
echo "create database assets; create user assets with encrypted password 'p4ssw0rd'; grant all privileges on database assets to assets;" | su - postgres -c psql
# give some more time for DB to start
-sleep 2
+sleep 5
# dump schema
DATABASE_URL=postgres://assets:[email protected]/assets RAILS_ENV=production bundle exec rake db:migrate db:schema:dump db:schema:cache:dump
@@ -38,3 +38,12 @@ rm -rf "$APP_PATH/node_modules/" "$APP_PATH/frontend/node_modules/"
# Clean cache in root
rm -rf /root/.npm
+rm -f "$APP_PATH/log/production.log"
+
+cat > "$APP_PATH/config/database.yml" <<CONF
+production:
+ url: <%= ENV.fetch("DATABASE_URL") %>
+ variables:
+ # https://github.com/ankane/the-ultimate-guide-to-ruby-timeouts#postgresql
+ statement_timeout: <%= ENV.fetch("POSTGRES_STATEMENT_TIMEOUT", "90s") %>
+CONF