Skip to content

Instantly share code, notes, and snippets.

View andrwng's full-sized avatar

Andrew Wong andrwng

View GitHub Profile
@andrwng
andrwng / poweroftwochoices.py
Last active October 4, 2019 05:21
Power of two choices implementation for group selection in python
#!/usr/bin/python
import random
import numpy as np
from matplotlib import pyplot as plt
"""
Straight-forward implementation of PO2C.
"""
def po2c(num_buckets, num_groups, group_size):
commit cbe7087ac3539cf342135436f230c36f7812203e
Author: Andrew Wong <awong@cloudera.com>
Date: Wed Nov 15 08:04:09 2017 -0800
Error handle on the way up
Change-Id: If338be326dd9922c8c6cc2a03bfeebd85894c208
diff --git a/src/kudu/tablet/delta_tracker.cc b/src/kudu/tablet/delta_tracker.cc
index 613d0e2..20d8577 100644
commit c1edad735f3520ca60190a0016f0ac118156a8f3
Author: Andrew Wong <awong@cloudera.com>
Date: Wed Nov 15 08:04:09 2017 -0800
Trigger error handling upon leaving carnage
Change-Id: If338be326dd9922c8c6cc2a03bfeebd85894c208
diff --git a/src/kudu/fs/fs_manager.h b/src/kudu/fs/fs_manager.h
index faf9aa0..3610df4 100644
@andrwng
andrwng / create_faulty_mount.sh
Created December 7, 2017 21:10
script to create a faulty mount
#!/usr/bin/bash
#
# Script to create a faulty directory.
# Canonicalize the input directory.
faulty_device=`readlink -f $1`
echo Using file as the base of the loop device: $faulty_device
# Create a file large enough to hold the fs. The minimum size is 512B.
# Adjust `bs` based on the output of `state -f "%k" .` (tells you the block size of `.`)
I0306 00:17:15.490319 307 raft_consensus.cc:2012] T e1d15822abc748239abee3de00d23450 P 01076373237e457d9d20570e9915cc7b [term 1 FOLLOWER]: Raft consensus shutting down.
I0306 00:17:15.490316 306 tablet_service.cc:755] Processing CreateTablet for tablet c926cb59d3d24e8596a8554365f4e3ea (table=test-table [id=59728a33a7134d979cc23bea31f8e515]), partition=RANGE (c531) PARTITION 2080374753 <= VALUES < 2147483616
I0306 00:17:15.490334 307 pending_rounds.cc:63] T e1d15822abc748239abee3de00d23450 P 01076373237e457d9d20570e9915cc7b: Trying to abort 2 pending transactions.
I0306 00:17:15.490439 307 pending_rounds.cc:68] T e1d15822abc748239abee3de00d23450 P 01076373237e457d9d20570e9915cc7b: Aborting transaction as it isn't in flight: id { term: 1 index: 16 } timestamp: 6227130103078129664 op_type: ALTER_SCHEMA_OP alter_schema_request { tablet_id: "e1d15822abc748239abee3de00d23450" schema { columns { id: 0 name: "c531" type: INT32 is_key: true is_nullable: false encoding: AUTO_ENCODING compression: DEFAULT_COMPRE
sudo -u kudu kudu remote_replica copy 44609e2f1bec4f528f0b0307bf6a2380 newnode6 newnode2 -force_copy
sleep 1
sudo -u kudu kudu remote_replica copy 70579027316641e5a4d0954da7164242 newnode6 newnode2 -force_copy
sleep 1
sudo -u kudu kudu remote_replica copy 781b07eef0bf4d87869e4c91da46e6ab newnode4 newnode1 -force_copy
sleep 1
sudo -u kudu kudu remote_replica copy 379865b1839e47a5a70e1112e1e37032 newnode6 newnode2 -force_copy
sleep 1
sudo -u kudu kudu remote_replica copy 107a89ef8d774db082421430578a6db6 newnode6 newnode2 -force_copy
sleep 1
commit 4810fd8dd7db362a86e568caa5434832622706e2
Author: Andrew Wong <awong@cloudera.com>
Date: Wed May 23 15:24:27 2018 -0700
multiclient perf
Change-Id: Ie1e7764a11261c9d337853370ee4b5c745557fa7
diff --git a/src/kudu/tools/tool_action_perf.cc b/src/kudu/tools/tool_action_perf.cc
index 2aeb514..9235905 100644
FROM centos:centos6.6
# yum needs to be patched to run within Docker. See
# https://github.com/CentOS/sig-cloud-instance-images/issues/15 for more
# details.
RUN yum install -y yum-plugin-ovl
RUN yum update -y
RUN yum install -y \
# This script assumes you've populated the current directory with a Kudu repository.
# First, get rid of any crummy old docker installations lying around and install docker-ce.
rm /etc/systemd/system/docker.service.d/docker.conf || true
apt-get remove docker docker-engine docker.io
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
diff --git a/src/kudu/util/subprocess.cc b/src/kudu/util/subprocess.cc
index d68cb7f656f78847430887d4dfa0676d8392ee1a..8d3ef7dc752799785effbfd990a9b4700fcfd546 100644
--- a/src/kudu/util/subprocess.cc
+++ b/src/kudu/util/subprocess.cc
@@ -376,6 +376,10 @@ Status Subprocess::Start() {
// TODO: prctl(PR_SET_PDEATHSIG) is Linux-specific, look into portable ways
// to prevent orphans when parent is killed.
prctl(PR_SET_PDEATHSIG, SIGKILL);
+
+ // Allow the child process to be ptraced by any thread.