Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Pau Pérez Fabregat sauloperez

💭
I may be slow to respond.
View GitHub Profile
@sauloperez
sauloperez / cercles-coop.log
Created Nov 19, 2020
Cercles.coop stacktrace
View cercles-coop.log
2020-11-19T12:34:41.054839+00:00 app[web.1]: F, [2020-11-19T12:34:41.054744 #34] FATAL -- : [3a52ba07-f9a1-4a7e-bed6-25affba1b729] Rack::Timeout::RequestTimeoutException (Request waited 5ms, then ran for longer than 30000ms ):
2020-11-19T12:34:41.054840+00:00 app[web.1]: F, [2020-11-19T12:34:41.054787 #34] FATAL -- : [3a52ba07-f9a1-4a7e-bed6-25affba1b729]
2020-11-19T12:34:41.054961+00:00 app[web.1]: F, [2020-11-19T12:34:41.054886 #34] FATAL -- : [3a52ba07-f9a1-4a7e-bed6-25affba1b729] vendor/bundle/ruby/2.6.0/gems/excon-0.78.0/lib/excon/socket.rb:279:in `select'
2020-11-19T12:34:41.054962+00:00 app[web.1]: [3a52ba07-f9a1-4a7e-bed6-25affba1b729] vendor/bundle/ruby/2.6.0/gems/excon-0.78.0/lib/excon/socket.rb:279:in `select_with_timeout'
2020-11-19T12:34:41.054962+00:00 app[web.1]: [3a52ba07-f9a1-4a7e-bed6-25affba1b729] vendor/bundle/ruby/2.6.0/gems/excon-0.78.0/lib/excon/socket.rb:140:in `rescue in block in connect'
2020-11-19T12:34:41.054963+00:00 app[web.1]: [3a52ba07-f9a1-4a7e-bed6-25affba1b729] vendor/bundle
@sauloperez
sauloperez / development.rb
Created Jul 20, 2020
Complete production-like development-mode profiling environment
View development.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = !!ENV["PROFILE"]
# Do not eager load code on boot.
config.eager_load = !!ENV["PROFILE"]
View delivery.md

Delivery

Review of the process

We will check epics to see whether the criteria in terms of performance has been met.

Tech and Po check from time to time how we do in terms of reaching the goal and adapting.

Filipe is still finding his way and will share any process improvements as soon as he has grasps it all and has ideas.

@sauloperez
sauloperez / dump_with_compression.sh
Last active Jun 5, 2019
database dump with compression
View dump_with_compression.sh
pg_dump -U ofn_user -h localhost openfoodnetwork -Fc -f /tmp/production_dump.sql
# openfoodnetwork@production18:~/apps/openfoodnetwork/current$ du -h /tmp/production*
# 320M /tmp/production_dump_with_compression.sql
# 1.2G /tmp/production_dump_without_compression.sql
View .devenv
NAME="ofn"
DISTRIBUTION="ubuntu"
RELEASE="xenial"
ARCH="amd64"
HOST="ofn.local"
DEVENV_USER="ofn-admin"
DEVENV_GROUP="openfoodnetwork"
PROJECT_NAME="openfoodnetwork"
@sauloperez
sauloperez / order_management.sql
Created May 11, 2019
Order cycle management report in a single SQL query
View order_management.sql
select spree_line_items.order_id, spree_products.supplier_id, sum(spree_line_items.price * spree_line_items.quantity) AS amount
from spree_line_items
inner
join spree_variants
on spree_variants.id = spree_line_items.variant_id
inner
join spree_products
on spree_products.id = spree_variants.product_id
inner
join enterprises
@sauloperez
sauloperez / restart.txt
Created Apr 19, 2019
Detect when postgres needs a restart
View restart.txt
On Wed, Oct 1, 2014 at 2:18 PM, Stuart Bishop <stuart(at)stuartbishop(dot)net>
wrote:
> It is unnecessary maintaining a list of parameters which require a
> restart, as you can tell by looking at pg_settings.
>
> The way I do it is by comparing the contents of pg_settings with a
> snapshot I made just after (or just before) the server was last
View sloq_query_log.txt
Like most databases, Postgres has a built-in slow query log feature that automatically logs queries to the main Postgres log file if they take over a certain amount of time and it's really easy to set up.
In your main postgresql.conf file (which is often somewhere like /etc/postgresql/9.6/main/postgresql.conf), either edit or add a line like so:
log_min_duration_statement = 1000
After restarting Postgres or reloading the config with SELECT pg_reload_conf();, this directive causes any queries that take over 1000 milliseconds (one second) to be logged.
(The location of the log file varies but is /var/log/postgresql/postgresql-9.6-main.log on my test setup, for instance.)
To deliberately run a long query for testing purposes:
View Postgres_tips.txt
\watch
SELECT datname, usename, query FROM pg_stat_activity; \watch
You can’t perform that action at this time.