Skip to content

Instantly share code, notes, and snippets.

Brian Sparrow bsparrow435

Block or report user

Report or block bsparrow435

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@bsparrow435
bsparrow435 / riak_metrics.escript
Last active Aug 21, 2017
Escript to query various in-VM metrics on a Riak node not currently available from stats.
View riak_metrics.escript
-module(riak_metrics).
-compile(export_all).
main([NodeName0, Cookie, Length, Command]) ->
LocalName = 'riak_metrics@127.0.0.1',
NodeName = list_to_atom(NodeName0),
case net_kernel:start([LocalName]) of
{ok, _} ->
erlang:set_cookie(node(), list_to_atom(Cookie)),
case net_kernel:hidden_connect_node(NodeName) of
View delete_code_path.md
@bsparrow435
bsparrow435 / get_put_code.md
Last active Jan 19, 2018
Get/Put path walk through
View get_put_code.md
View heap_query.escript
-module(heap_query).
-compile(export_all).
main([NodeName0, Cookie]) ->
Name = 'heap_query@127.0.0.1',
NodeName = list_to_atom(NodeName0),
case net_kernel:start([Name]) of
{ok, _} ->
erlang:set_cookie(node(), list_to_atom(Cookie)),
case net_kernel:hidden_connect_node(NodeName) of
@bsparrow435
bsparrow435 / gist:7455997
Created Nov 13, 2013
OTP erlang has closed
View gist:7455997
/Users/bsparrow/Riak_git/otp/erts/etc/common/heart.c:
499 }
500 } else if (tlen == 0) {
501: /* Erlang has closed its end */
502: print_error("Erlang has closed.");
503 return R_CLOSED;
504 }
/Users/bsparrow/Riak_git/otp/erts/etc/common/inet_gethost.c:
541 return 1;
View repair.erl
-module(repair).
-compile(export_all).
main([Dir]) ->
Opts = [{max_open_files, 2000},
{use_bloomfilter, true},
{write_buffer_size, 45 * 1024 * 1024},
{compression,false}],
{Time,_} = timer:tc(eleveldb,repair,[Dir, Opts]),
@bsparrow435
bsparrow435 / ring.erl
Created Jul 31, 2013
This will identify the node/partitions that own a given bucket/key.
View ring.erl
Bucket = <<"d">>,
Key = <<"e0c97a4cde6c">>,
BKey = {Bucket,Key},
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
DocIdx = riak_core_util:chash_key(BKey),
BucketProps = riak_core_bucket:get_bucket(Bucket, Ring),
[NValue] = [Y || {X1, Y} <- BucketProps, n_val == X1],
UpNodes = riak_core_node_watcher:nodes(riak_kv),
Preflist2 = riak_core_apl:get_apl_ann(DocIdx, NValue, Ring, UpNodes),
Preflist = [{IndexNode, Type} || {IndexNode, Type} <- Preflist2].
View ML.md

Step 1: From you logs I have decoded the bucket/key

binary_to_term(<<131,109,0,0,0,9,85,114,108,84,111,83,99,97,110>>).
<<"UrlToScan">>
binary_to_term(<<131,109,0,0,0,61,104,116,116,112,37,51,97,37,50,102,37,50,102,119,119,119,46,97,110,104,114,105,46,110,101,116,37,50,102,37,51,102,102,101,101,100,37,51,100,114,115,115,50,37,50,54,97,109,112,37,51,98,112,37,51,100,55,51,49,49,48>>).
<<"http%3a%2f%2fwww.anhri.net%2f%3ffeed%3drss2%26amp%3bp%3d73110">>

Step 2: Please run the below snippits from riak attach to identify the owning partitions of this bucket/key

View yeah.erl
f().
Vnode = fun(Idx) ->
[{I,P}] = [ {Index,Pid} || {Mod,Index,Pid} <- gen_server:call(riak_core_vnode_manager,all_vnodes),Mod == riak_kv_vnode, Index == Idx],
{I,P}
end,
Vnodes = fun() ->
[ I || {Mod,I,P} <- gen_server:call(riak_core_vnode_manager,all_vnodes), Mod == riak_kv_vnode ]
end,
View extract_bitcask.erl
-module(extract_bitcask).
main([Dir, Output]) ->
{ok, Fh} = file:open(Output,[write]),
io:format("Dumping bucket/keys for partition: ~p to output file: ~p\n", [Dir,Output]),
F = fun(Entry, _Acc) ->
case Entry of
{bitcask_entry, Key, _S, _T, _F, _U} ->
{B, K} = binary_to_term(Key),
erlang:put(extraction_counter, erlang:get(extraction_counter) + 1) ,
You can’t perform that action at this time.