Skip to content

Instantly share code, notes, and snippets.

View remove_containers.rb
#!/usr/bin/env ruby
# Don't remove devops containers that might be databases
def database_container?(line)
line.match?(/postgres/) || line.match?(/redis/)
end
# docker ps -f "before=containerId" | grep expression > /var/tmp/containers.txt
File.open('/var/tmp/containers.txt').each do |line|
next if database_container?(line)
@jedprentice
jedprentice / gist:4e3dfba017b0b4d29ef3102bee1f1069
Created Oct 18, 2018
How to find out which query is holding a lock in MySQL
View gist:4e3dfba017b0b4d29ef3102bee1f1069
mysql> SELECT r.trx_id waiting_trx_id, r.trx_mysql_thread_id waiting_thread, r.trx_query waiting_query,
b.trx_id blocking_trx_id, b.trx_mysql_thread_id blocking_thread, b.trx_query blocking_query
FROM information_schema.innodb_lock_waits w
INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id
INNER JOIN information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id\G
@jedprentice
jedprentice / jed.cnf
Last active Oct 25, 2019
MySQL 8 configuration; on Ubuntu this is included by my.cnf, so some of the most basic settings are not present. Values in this file override those in my.cnf.
View jed.cnf
[mysqld]
# Slow Log
#slow_query_log = 1
#log_queries_not_using_indexes = 1
#long_query_time = 1
# Allow GROUP BY to work like it did before MySQL 5.7.5, for Rails 3.2
# compatibility, i.e., remove ONLY_FULL_GROUP_BY from the default
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"