Skip to content

Instantly share code, notes, and snippets.

View nickva's full-sized avatar

Nick Vatamaniuc nickva

  • USA
View GitHub Profile
@nickva
nickva / distblockleak.erl
Created November 7, 2023 06:17
Reproducer for a binary memory leak across a dist channel on OTP 24+
%
% $ erl -name [email protected]
% > c(distblockleak).
%
% $ erl -name [email protected]
% > c(distblockleak), distblockleak:go('[email protected]', "./junk.bin", 10000, 100, 200).
%
-module(distblockleak).
@nickva
nickva / multiuser.py
Last active November 9, 2023 04:34
Test script to generate a lot of CouchDB regular and admin users
#!/usr/bin/env python
#
# make && ./dev/run -n 1 --admin=adm:pass
# ./multiuser.py --users-scheme=simple --users-salt="abc" --users-hash-sha1 --tries 100
import copy
import sys
import time
import threading
import os
@nickva
nickva / chnagesrevtree.sh
Created January 4, 2024 22:56
Various changes feed parameters for Apache CouchDB
#!/bin/bash
http -q delete $DB/db
http -q put $DB/db
http post $DB/db/_bulk_docs new_edits:='false' docs:='[{"_id":"d1", "_revisions":{"start":2, "ids":["x", "z"]}, "data":1}, {"_id":"d1", "data":2, "_revisions":{"start":2, "ids":["y", "z"]}}, {"_id":"d1", "data":3, "_deleted":true, "_revisions":{"start":2, "ids":["w", "z"]}}]'
http -q put $DB/db/d1/att2y'?rev=2-y' data=2y
http -q put $DB/db/d1/att2x'?rev=2-x' data=2x
echo "Without a filter with atts"
@nickva
nickva / findlimit.py
Last active January 30, 2024 06:18
Mango execution stats checker
#!/usr/bin/env python
import json
import time
import requests
import string
import random
S = requests.session()
@nickva
nickva / couch_event_bench.erl
Created February 11, 2024 06:33
CouchDB Event Server Benchmark
% Benchmark module for couch_event_server
%
% Benchmark registering/unregistering N listeners for N dbs. Then benchmark
% sending 10 events from concurrent proceses for each of the Db and measure
% event latency: how long it took for the event to be delivered to the
% listener.
%
% Times are measured in microseconds. Best (minimum) results are returned for each
% of the N cases.
%
@nickva
nickva / ddoc_cache_bench.erl
Created February 16, 2024 20:54
Apache CouchDB ddoc_cache_lru benchmark
% Benchmark module for ddoc_cache_lru
%
% Benchmark opening and closing (evicting) a bunch of random dbs/ddocs.
%
% Times are measured in microseconds. Best (minimum) results are returned for each
% of the N cases.
%
-module(ddoc_cache_bench).
@nickva
nickva / example.erl
Created May 20, 2024 15:51
New Erlang json module, sigils and triple quoted strings
> json:decode(~"""
{"a":"b", "c":true, "d":42, "e":1.2, "f":false, "g":null}
""").
#{<<"a">> => <<"b">>,<<"c">> => true,<<"d">> => 42,
<<"e">> => 1.2,<<"f">> => false,<<"g">> => null}
% ./enc
=ERROR REPORT==== 22-May-2024::15:14:05.001026 ===
beam/beam_load.c(607): Error loading function rebar:log/3: op init y:
no specific operation found
escript: exception error: undefined function rebar:main/1
in function escript:run/2 (escript.erl, line 904)
in call from escript:start/1 (escript.erl, line 418)
in call from init:start_it/1
@nickva
nickva / remsh.erl
Last active May 23, 2024 17:09
recon trace return errors only
> recon_trace:calls({fabric, design_docs, fun(_) -> exception_trace() end}, 10, [
{formatter, fun
({trace, _, exception_from, MFA, Err}) -> io_lib:format("|~p:~p|~n", [MFA,Err]);
({trace, _, return_from, MFA, {IsOk,_}=Res}) when IsOk =/= ok -> io_lib:format("|~p:~p|n", [MFA,Res]);
(_) -> ""
end}
]).
@nickva
nickva / create_and_poll_reps.py
Created October 14, 2024 17:02
Create and monitor Apache CouchDB replication documents
#!/usr/bin/env python
# Run with an n=1 dev/run test cluster
# Needs python 3.7 minimum
#
# $ virtualenv -p python3 venv3
# $ . venv3/bin/activate
# $ pip install requests
# make && ./dev/run -n 3 --with-haproxy --admin=adm:pass