Skip to content

Instantly share code, notes, and snippets.

View angrycub's full-sized avatar

Charlie Voiselle angrycub

View GitHub Profile

A Debugging Technique

ohmyzsh/ohmyzsh#5327

I didn't read every post here, but I'm gonna post a technique for debugging slow startup just in case no one else has posted a good one yet.

If you install the moreutils package, you'll have a timestamp command called ts. You can use it to print sub-second resolution timestamps of all of the debug output from zsh that tell you how long since the last line of output. You can then search that file for timestamps that are "long". Here's the command:

zsh -xv 2>&1 | ts -i "%.s" > zsh_startup.log
@angrycub
angrycub / .colors.tsv
Last active February 28, 2025 23:50 — forked from avillafiorita/.colors.csv
change osx terminal colors and font from the command line
LightPink1 #ffbdc5 255 189 197 {65535, 48573, 50629}
pink4 #9d777f 157 119 127 {40349, 30583, 32639}
pink3 #d7a3ad 215 163 173 {55255, 41891, 44461}
pink2 #f2b9c4 242 185 196 {62194, 47545, 50372}
pink1 #ffc3cf 255 195 207 {65535, 50115, 53199}
HotPink4 #9e4f75 158 79 117 {40606, 20303, 30069}
HotPink3 #d878a1 216 120 161 {55512, 30840, 41377}
HotPink2 #f383b5 243 131 181 {62451, 33667, 46517}
HotPink1 #ff87c1 255 135 193 {65535, 34695, 49601}
DeepPink4 #9e1e62 158 30 98 {40606, 7710, 25186}
@angrycub
angrycub / provision_ubuntu2004_qemu_macosx.sh
Created August 8, 2024 19:04 — forked from relyt0925/provision_ubuntu2004_qemu_macosx.sh
Provisions a Ubuntu 20.04 VM in QEMU on Mac OSX using Cloud-Init
#!/usr/bin/env bash
#Install brew and qemu + cloud init metadata dependencies
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install qemu
brew install cdrtools
rm -rf /tmp/ubuntuqemuboot
#download Ubuntu 20.04 Cloud Image and resize to 30 Gigs
mkdir -p /tmp/ubuntuqemuboot/images
@angrycub
angrycub / pinger.erl
Created May 9, 2017 18:14 — forked from lukebakken/pinger.erl
Ping Riak nodes
-module(pinger).
-export([ping/1,
ping/3,
pinglist/4,
pingall/0,
pingall/1,
pingall/2
]).
#!/usr/bin/env escript
%% -*- erlang -*-
-include_lib("kernel/include/file.hrl").
-compile(export_all).
-define(LOG(S), io:format(S)).
-define(LOG(S,A), io:format(S,A)).
main(Dirs) ->
CodePath = case os:getenv("RIAK_LIB") of

Summary

LevelDB can become corrupted when bad things happen on the filesystem or in hardware. We push the I/O to the limits on heavily loaded Riak nodes so it is not uncommon to experience such failures. This one exhibits as a message Compaction error: Corruption: corrupted compressed block contents in the «data_root»/leveldb/«vnode»/LOG file.

Diagnosis

Steps that pin-point this issue

[root@prod-2163 /var/db/riak/leveldb]# find . -name "LOG" -exec grep -l 'Compaction error' {} \; 
./442446784738847563128068650529343492278651453440/LOG 
PBStatusFun = fun() ->
VnodePids = [Pid || {_, Pid} <- riak_core_vnode_manager:all_index_pid(riak_kv_vnode)],
Links = [process_info(Pid, [links]) || Pid <- VnodePids],
WorkerPoolPids = [WPPid || [{links,[_, WPPid]}] <- Links],
WorkerPoolLinks = [process_info(Pid, [links]) || Pid <- WorkerPoolPids],
PoolboyPids = [PoolboyPid || [{links,[_, PoolboyPid]}] <- WorkerPoolLinks],
[poolboy:status(Pid) || Pid <- PoolboyPids]
end.
PBStatusFun = fun(Index) ->
% Purpose: I use this pre-commit hook to mark objects in a bucket as "dirty" with secondary indexing.
% I then use a script to scrape out all dirty objects, do some processing, then save them with
% "dirty_bin = false" as an index and the pre-commit hook erases the "dirty_bin" index.
% So in essence it works as: `if dirty_bin = false; del dirty_bin; else dirty_bin = true; end`
%
% To install this pre-commit hook (just like any Riak pre-commit hook in Erlang), you need to create an Erlang file and
% put it in your "basho-patches" directory. For me, on Ubuntu, this was "/usr/lib/riak/lib/basho-patches".
% Once there, you need to compile it to a .beam file. This was helped by using the Riak provided erlc compiler,
% which, on my Ubuntu system, was at "/usr/lib/riak/erts-5.8.5/bin/erlc"
%