Skip to content

Instantly share code, notes, and snippets.

@dotmanila
dotmanila / php-xdebug.sh
Created November 29, 2015 06:04
Running XDebug Function Trace from Command Line
#!/bin/bash
php -d xdebug.collect_params=4 -d xdebug.collect_return=1 \
-d xdebug.collect_includes=1 -d xdebug.auto_trace=1 pareto.t.php
@dotmanila
dotmanila / callgrind-with-mysql.txt
Last active November 29, 2015 06:34
MySQL Thread Running "SELECT SLEEP(10)" via callgrind
# Ran with valgrind --tool=callgrind mysqld ...
# mysql -e 'select sleep(10)'
# callgrind_control -b
Frame: Backtrace for Thread 24
[ 0] pthread_cond_timedwait@@GLIBC_2.3.2 (1 x)
[ 1] Interruptible_wait::wait(st_mysql_cond*, st_mysql_mutex*) (1 x)
[ 2] Item_func_sleep::val_int() (1 x)
[ 3] Item::send(Protocol*, String*) (2 x)
[ 4] Protocol::send_result_set_row(List<Item>*) (2 x)
@dotmanila
dotmanila / C3P0DataSourceExample.java
Created February 25, 2016 05:51
Sample Java Source Code utilizing connection pools fom DataSource.java.
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Instant;
public class C3P0DataSourceExample {
@dotmanila
dotmanila / DataSource.java
Created February 25, 2016 05:52
Java source code, using connection pool with c3p0
import java.beans.PropertyVetoException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import com.mchange.v2.c3p0.ComboPooledDataSource;
public class DataSource {
private static DataSource datasource;
@dotmanila
dotmanila / dump-per-table-recovery.sh
Created October 10, 2016 00:09
Dump data from a crashing MySQL server with corrupt pages.
#!/bin/bash
pid_file_path=/var/lib/mysql/mysqld.pid
for d in $(cat dbs-list.txt); do
#if ! grep $d important-dbs.txt; then continue; fi
mysql $d -BNe 'show tables' > /tmp/tables.txt
for t in $(cat /tmp/tables.txt); do
while true; do
test -s "$pid_file_path" && break
@dotmanila
dotmanila / ZFS_and_ext4_Configuration.txt
Last active December 27, 2022 04:56
ZFS and ext4 Configuration
# Create ext4 RAID
sudo mdadm --create --verbose /dev/md0 --level=10 --raid-devices=4 \
--name=mysql /dev/sdb /dev/sdc /dev/sdd /dev/sde
sudo mkdir /mysql-ext4
sudo mkfs.ext4 /dev/md0
sudo mount -o rw,relatime /dev/md0 /mysql-ext4
sudo mkdir /mysql-ext4/msb
sudo chown revin.revin /mysql-ext4/msb
@dotmanila
dotmanila / Vagrantfiles.txt
Created September 20, 2017 17:58
Random Vagrantfiles for quick tests.
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
@dotmanila
dotmanila / dsync-benchmark.txt
Created September 28, 2017 14:32
O_DSYNC Benchmark on GCE with Percona Server
env SANDBOX_BINARY=/home/jervin/mysql make_sandbox 5.7.190 -- \
--upper_directory=/mysql-ext4/msb --my_clause=innodb_buffer_pool_size=38G \
--my_clause=innodb_log_file_size=536870912 --my_clause=innodb_flush_method=O_DIRECT \
--my_clause=bind-address=0.0.0.0 --my_clause=skip_name_resolve=1 \
--my_clause=thread_cache_size=48 --my_clause=performance_schema=off \
--my_clause=max_allowed_packet=33554432 --my_clause=innodb_page_cleaners=8 \
--my_clause=innodb_lru_scan_depth=2048 --my_clause=innodb_io_capacity=5000 \
--my_clause=innodb_io_capacity_max=10000 --my_clause=innodb_flushing_avg_loops=5 \
--my_clause=innodb_flush_neighbors=2 --my_clause=innodb_buffer_pool_instances=8
@dotmanila
dotmanila / zfs-encryption.sh
Created November 1, 2017 16:35
ZFS on Linux Encrypted Crash/Exchange Error
#!/bin/bash
DISK=xvdb
BACKUPVOL=xvdc
USER=ubuntu
KERNEL=$(uname -r)
wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
sudo dpkg -i percona-release_0.1-4.xenial_all.deb
sudo apt -y update
@dotmanila
dotmanila / zfs-bootstrap-ubuntu-16.04.sh
Last active November 8, 2017 22:08
ZFS bootstrap Ubuntu 16.04 with default ZFS version, uses xvdb for single vdev and PXC 5.7.19 using MySQL sandbox.
#!/bin/bash
DISK=xvdb
USER=ubuntu
IP=$(ip -4 ad sh scope global | grep 'scope global' | awk '{print $2}' | cut -d'/' -f1 | head -n1)
KERNEL=$(uname -r)
wget https://repo.percona.com/apt/percona-release_0.1-4.$(lsb_release -sc)_all.deb
sudo dpkg -i percona-release_0.1-4.xenial_all.deb
sudo apt -y update