<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rhishikesh Joshi on Medium]]></title>
        <description><![CDATA[Stories by Rhishikesh Joshi on Medium]]></description>
        <link>https://medium.com/@rhishikeshj?source=rss-40e7baec56c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*j1Bqq3ZEA5wEufBA.jpg</url>
            <title>Stories by Rhishikesh Joshi on Medium</title>
            <link>https://medium.com/@rhishikeshj?source=rss-40e7baec56c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:54:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rhishikeshj/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A mental model to think about transducers]]></title>
            <link>https://rhishikeshj.medium.com/a-mental-model-to-think-about-transducers-1e88af1ccf2b?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e88af1ccf2b</guid>
            <category><![CDATA[helpshift]]></category>
            <category><![CDATA[transducers]]></category>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[functional-programming]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Tue, 06 Apr 2021 08:51:47 GMT</pubDate>
            <atom:updated>2021-04-06T08:51:47.941Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Clojure’s documentation describes Transducers as composable algorithmic transformations. They are transformations which are independent of input or output and they compose without awareness of input or creation of aggregate values.</p><p>When talking about transducers, we should look at the original thing that gave rise to this abstraction. The <strong>reduction</strong></p><p>A reducing function is essentially any function that you can pass to a reduce call. This function is supposed to take the result so far, <em>generally known as the accumulator</em> and the new value and generate a new result. So a reducing function is</p><pre>accumulated-result, input -&gt; accumulated-result</pre><p>While a transducer is the more general transformation defined as something which takes a reducing function and returns a new reducing function</p><pre>(accumulated-result, input -&gt; accumulated-result) -&gt; (accumulated-result, input -&gt; accumulated-result)</pre><p>The primary power of transducers comes from their fundamental decoupling — they don’t care (or know about):</p><ul><li>The ‘job’ being done (what the reducing function does)</li><li>The context of use (what ‘whatever’ is)</li><li>The source of inputs (where input comes from)</li></ul><p>Now all this sounds really fancy, but I always have a hard time wrapping my head around abstract terminology like this before I understand the nuts and bolts of it. So in this post, we will walk through a very simple and elegant way of building up your thinking about transducers. I am in no way an expert at this but this has definitely helped me understand the concepts thoroughly and find joy in applying these techniques in my day to day work.</p><h3>Down the rabbit hole</h3><p>As described in the official documentation and <a href="https://www.youtube.com/watch?v=4KqUvG8HPYo">this talk</a>, the origin of the idea of transducers is the reducer. So lets start by writing a very simple function</p><h3>How to write map in terms of a reduction</h3><pre>(defn rmap [f coll]<br>  (reduce (fn [acc v]<br>            (conj acc (f v)))<br>          []<br>          coll))</pre><p>Simple enough, reduce over the collection, conj a value into the accumulator. This value is the result of applying the function f on the value which gives us the map</p><h3>How to write filter in terms of a reduction</h3><pre>(defn rfilter [f coll]<br>  (reduce (fn [acc v]<br>            (if (f v)<br>              (conj acc v)<br>              acc))<br>          []<br>          coll))</pre><p>Again, reduce over the collection, but now only conj a value if the predicate returns true.</p><p>Let us look at these functions closely and try to identify where there is tight coupling. One of the first things that should jump out is the use of conj and the empty vector passed as the initial value. These are sequence building operations and strictly speaking nothing to do with the tranformations i.e the map and filter operations.</p><p>Let’s try and isolate out the reducing functions of map and filter from the sequence building. We can focus on just the internal anonymous functions above which take an accumulator and a value and return a new accumulated result</p><pre>(defn mapping [f]<br>  (fn [acc v]<br>    (conj acc (f v))))<br></pre><pre>(defn filtering [f]<br>  (fn [acc v]<br>    (if (f v)<br>      (conj acc v)<br>      acc)))</pre><p>This allows us to pull out the reducing logic from everywhere and put it in one place like this</p><pre>(def data (vec (range 20)))</pre><pre>(reduce (mapping inc)<br>        []<br>        data)</pre><p>This is a step in the right direction. Now our transformation is independent and we can supply an initial value of the result as we desire. But the coupling of the conj and the map is still a concern.</p><h3>Parameterize the sequence builder</h3><p>Lets take the function which builds the sequence as an argument ! How would that look ?</p><pre>(defn trans-mapping<br>  &quot;Take f as argument and return a function which takes<br>  conj as an argument and applies f&quot;<br>  [f]<br>  (fn [xf]<br>   (fn [acc v]<br>     (xf acc (f v)))))<br></pre><pre>(defn trans-filtering [f]<br>  (fn [xf]<br>     (fn [acc v]<br>       (if (f v)<br>         (xf acc v)<br>         acc))))</pre><p>Let’s take minute to see exactly what is happening here. trans-mapping takes a function just like a map would. But instead of returning a value, it returns another function which can take any sequence building function like conj ! That&#39;s promising right ? Now our initial value and the sequence building operations are both independent of the actual transformation. Let&#39;s update our test code from earlier</p><pre>;; Let&#39;s build a mapping which squares its input value<br>(def rfn (trans-mapping #(* % %)))</pre><pre>(reduce (rfn conj)<br>        []<br>        data)</pre><p>But if you look very closely, you realise that conj isn&#39;t really very special here. Nor is the [] initial value. We can just as easily substitute both of them for an operation which adds something and an initial value to start with. So why not do this ?</p><pre>(reduce (rfn +)<br>        0<br>        data)</pre><p>What do you know ! This works too :D It will add squares of all numbers in the data sequence.</p><h3>Composing transformations</h3><p>Consider a case of a composite reduce function</p><pre>(def rfn (comp (trans-mapping inc)<br>               (trans-filtering even?)))</pre><p>Now if we look at the rfn function what is it&#39;s arity and what are the arguments ? rfn is the function returned by trans-mapping and/or trans-filtering and so it has an arity of 1. It takes the sequence building function and returns the transformation function. (rfn +) -&gt; transformation function.</p><p>The transformation function takes 2 arguments, the first argument is the accumulated result and second argument is the new value.</p><pre>;; So this is a very valid way of using rfn<br>((rfn +) 42 5)</pre><p>What do you think this returns ? comp applies it&#39;s functions from right to left, so first it will check whether the value is even and if it is, it will increment it. So in our case, this should fail at the filter stage since 5 is odd. But if you run this code, you will see the result to be 48!</p><p>This happens because rfn will first do a map and then a filter. comp is still doing the application right-to-left. But the way our trans-mapping function works nests the mapping inside the filtering. In its expanded form, the comp form actually turns into</p><pre>(((trans-mapping inc)<br>  ((trans-filtering even?) +)) 42 5)</pre><p>Now the trans-filtering form takes the + fn and embeds it inside its own transformation as the xf argument, and returns a function which adds to its accumulator if the input is even. This function is passed in turn to the trans-mapping form which embeds it inside its own returned function as the xf and applies inc to its argument. Let&#39;s see a couple of expanded forms</p><pre>(((fn [xf] ;; trans-mapping<br>    (fn [acc v]<br>      (xf acc (inc v)))) ((fn [acc v] ;; trans-filtering<br>                            (if (even? v)<br>                              (+ acc v)<br>                              acc)))) 42 5)</pre><pre>;; Now if we replace the xf in the trans-mapping form<br>;; with the function returned by trans-filtering</pre><pre>((fn [acc v]<br>   ;; (trans-filtering even?) is the function being mapped<br>   ;; with + as the sequence builder<br>   ((fn [acc v]<br>      (if (even? v)<br>        (+ acc v)<br>        acc)) acc (inc v)))<br> 42 5)</pre><p>So as you can see, due to the way the trans-mapping and trans-filtering functions nest its arguments, comp&#39;s RTL application results in actual application to the inputs in LTR order, i.e inc first and even? later.</p><p>Keep this in mind. This is important when you build transformation pipelines with comp and clojure’s built in tranducers.</p><h3>Custom reducing functions</h3><p>Till now we have seen some built-in reducing functions like conj and + but we are not really restricted to using only built-in functions. Let’s try and write a string-rf function which essentially builds a string instead of a vector.</p><pre>(defn string-rf<br>  [^StringBuilder acc ^Character c]<br>  (.append acc c))</pre><p>Simple enough, it takes an accumulator and a character, calls .append on it to return a StringBuilder.</p><p>Now let’s see how we can use such a reducing function.</p><pre>(def xform<br>  (comp<br>    (map int)<br>    (filter odd?)<br>    (map char)))</pre><pre>(str (reduce (xform string-rf)<br>             (StringBuilder.) ;; Initialise<br>             &quot;Hello world&quot;))</pre><p>Here we call reduce with the transformation which takes the string-rf instead of the conj or + functions as above. So you can imagine how it will use the string-rf function to append to the sequence, essentially used as the xf argument.</p><p>For the reduction to work correctly, we have to give it a sane initial value so a new StringBuilder instance is as good a value as any. And as seen above since string-rf returns another StringBuilder, we have to call str on it to get an actual string.</p><h3>A multi-arity reducing function</h3><p>In the code above, the initialization and final realisation of the value is still too tighly coupled in the reduce call. It has to be a StringBuilder and we have to call str on it. But if you look closely these are the requirements of the string-rf function which are leaking out ! Can we do better ? Ofcourse we can... What if we let the same string-rf function tell us how to initialise the sequence. That could be achieved by having another arity which takes no args and returns a new StringBuilder, right ?</p><pre>(defn string-rf<br>  ;; this is to build a new string-builder<br>  ([] (StringBuilder.))<br>  ;; this is the construction<br>  ([^StringBuilder acc ^Character c]<br>   (.append acc c)))</pre><p>Now, string-rf can also tell us how to realise / get the final value out of the transformation. In this final step, string-rf actually needs only 1 arg, right ? So let&#39;s use that arity.</p><pre>(defn string-rf<br>  ;; this is to build a new string-builder<br>  ([] (StringBuilder.))<br>  ;; this is to convert the return value<br>  ([^StringBuilder s] (.toString s))<br>  ;; this is the construction<br>  ([^StringBuilder acc ^Character c]<br>   (.append acc c)))</pre><p>And voila! What do you know, you have yourselves a transducer. So let’s use it with the transducefunction !</p><pre>;; first arg is the transformation<br>;; second arg is how you build the collection<br>(transduce xform string-rf &quot;Hello World&quot;)</pre><p>This form is equivalent to</p><pre>;; This is equivalent to<br>(let [f (xform string-rf)]<br>  (f (reduce f (f) &quot;Hello World&quot;)))</pre><p>If you notice above, I used map and filter to create the xform instead of trans-mappingand trans-filtering. Why do you think that is ?</p><p>Well, that’s because similar to the reducing function, now the transformation also needs to handle multiple arities. So let’s change our mapping and filtering functions to do that !</p><pre>(defn mapping<br>  [f]<br>  (fn [xf]<br>    (fn<br>      ([] (xf))<br>      ([acc] (xf acc))<br>      ([acc v]<br>       (xf acc (f v))))))<br></pre><pre>(defn filtering<br>  [f]<br>  (fn [xf]<br>    (fn<br>      ([] (xf))<br>      ([acc] (xf acc))<br>      ([acc v]<br>       (if (f v)<br>         (xf acc v)<br>         acc)))))<br></pre><pre>;; and now the xform can look like<br>(def xform<br>  (comp (mapping int)<br>        (mapping inc)<br>        (filtering even?)<br>        (mapping char)))</pre><p>Now if you peer into the implementations of functions which returns transducers, you will see something exactly like these functions above ! And that’s all there is to transducers really. The rest of the magic, is as always, in we the programmer decide to use it !</p><p>Finally, let me leave you with a simple template for any custom transducers that you may want to write.</p><pre>(defn template-transducer [xf]<br>    (fn<br>      ([] (xf)) ;; Setup<br>      ([result input] (xf result input)) ;; Process<br>      ([result] (xf result))))</pre><p>But given the power of clojure’s built-in functions, it’s unlikely that you will ever need to write your own tranducers, but it’s always fun to know how you can !</p><h3>Use-cases for transducers</h3><p>By now, hopefully you understand what goes on behind the scenes of transducers. But understanding where to use them <em>and where to not use them</em> is still a skill we can only build with time as we see and write more and more code. But it’s always nice to start with some pointers there, and there’s no better place than Clojure’s <a href="https://clojure.org/guides/faq#transducers_vs_seqs">own docs</a> to get you started.</p><p><strong>Credits</strong> <a href="https://www.youtube.com/watch?v=6mTbuzafcII">Transducers talk by Rich Hickey</a> <a href="https://tbaldridge.pivotshare.com/categories/transducers/2426/media">Pivotshare tutorial by Tim Baldrige</a></p><p><em>Originally published on my [tech blog](</em><a href="https://rhishikesh.com/posts/how_i_think_about_transducers/">https://rhishikesh.com/posts/how_i_think_about_transducers/</a><em>)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e88af1ccf2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Jepsen toolkit Part 2]]></title>
            <link>https://rhishikeshj.medium.com/understanding-the-jepsen-toolkit-part-2-ae332260d9b4?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae332260d9b4</guid>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[jepsen]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Tue, 06 Apr 2021 08:51:10 GMT</pubDate>
            <atom:updated>2021-04-06T08:58:30.011Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This blog is the second part of a blog series on Understanding the Jepsen toolkit for Distributed systems testing. I would encourage you to go through </em><a href="https://rhishikeshj.medium.com/understanding-the-jepsen-toolkit-ba733fdab786"><em>part 1</em></a><em> before continuing on here.</em></p><h3>Major components of a Jepsen test</h3><h3>Generators</h3><p>A Jepsen history is a list of operations — invocations and completions. A generator’s job is to specify what invocations to perform, and when. In a sense, a generator’s output becomes a history as Jepsen incrementally applies it to a database.</p><p>Conceptually, then, a generator is a graph of events, some of which have not yet occurred. Some events are invocations: these are the operations the generator will provide to clients. Some events are completions: these are provided by clients to the generator. Other events are temporal: a certain time has passed.</p><p>This event graph has some invocations which are ready to perform. When jepsen sees a ready invocation, it applies the invocation using the client, obtains a completion, and applies the completion back to the graph, obtaining a new graph.</p><p>The generator protocol contains 2 methods. op and update</p><pre>(defprotocol Generator<br>  (update [gen test context event]<br>          &quot;Updates the generator to reflect an event having taken place.&quot;)</pre><pre>  (op [gen test context]<br>      &quot;Obtains the next operation from this generator.&quot;))</pre><p>The jepsen code calls (op gen test context) to ask the generator for the next invocation that should be processed.</p><p>The operation can have three forms:</p><ol><li>The generator may return nil, which means the generator is done, and there is nothing more to do. Once a generator does this, it must never return anything other than nil, even if the context changes.</li><li>The generator may return :pending, which means there might be more ops later, but it can&#39;t tell yet.</li><li>The generator may return an operation, in which case:</li></ol><ul><li>If it’s time is in the past, it can be evaluated now</li><li>If it’s time is in the future, jepsen’s test runner will wait until either the time arrives OR circumstances change (e.g. we update the generator)</li></ul><p>But (op gen test context) returns more than just an operation; it also returns the subsequent state of the generator, if that operation were to be performed. The two are bundled into a tuple.</p><pre>(op gen test context) =&gt; [op gen&#39;] ; known op and subsequent state</pre><pre>[:pending gen] ; unsure and same state</pre><pre>nil ; exhausted</pre><h4>Default generators</h4><p>There are some default generators which can be used for writing tests. They are,</p><p>nil is a valid generator; it ignores updates and always yields nil for all operations.</p><p>IPersistentMaps are generators which ignore updates and return exactly one operation which looks like the map itself, but with default values for time, process, and type provided based on the context. This means you can write a generator like</p><pre>{:f :write, :value 2}</pre><pre>;; and it will generate a single op like<br>{:type :invoke, :process 3, :time 1234, :f :write, :value 2}</pre><p>To produce an infinite series of ops drawn from the same map, use</p><pre>(repeat {:f :write, :value 2})</pre><p>Sequences are generators which assume the elements of the sequence are themselves generators. They ignore updates, and return all operations from the first generator in the sequence, then all operations from the second, and so on.</p><p>Functions are generators which ignore updates and can take either test and context as arguments, or no args. When a function is used as a generator, its return value is used as a generator; that generator is used until exhausted, and then the function is called again to produce a new generator. For instance:</p><pre>; Produces a series of different random writes, e.g. 1, 5, 2, 3...<br>(fn [] {:f :write, :value (rand-int 5)})</pre><pre>; Alternating write/read ops, e.g. write 2, read, write 5, read, ...<br>(fn [] (map gen/once [{:f :write, :value (rand-int 5)}<br>                      {:f :read}]))</pre><p>Promises and delays are generators which ignore updates, yield :pending until realized, then are replaced by whatever generator they contain. Delays are not evaluated until they could produce an op, so you can include them in sequences, phases, etc., and they&#39;ll be evaluated only once prior ops have been consumed.</p><p>Look at the extend-protocol implementation for Generator in the jepsen.generator.purenamespace for more details on default implementations</p><h4>Wrapper generators</h4><p>Built on this mechanism there are wrapper generators provided out of the box which do things like handle exceptions in the generator functions and convert them into ::op-threw and ::update-threw events. There is also a wrapper for adding traces ie. trace</p><p>There are wrappers for map and f-map which can transform the value generated by the generator (f op) and pass updates to underlying generator as is.</p><p>There is a filter wrapper for filtering out ops which don’t match a predicate.</p><p>There are any, mix, limit and repeat wrappers which do pretty much what you expect them to.</p><p>There are timing related wrappers like time-limit, delay and stagger which help add limit on op generation and delays respectively.</p><p>phases is an important wrapper because it ensures all ops from previous generator are exhausted before moving to the next generator in the chain.</p><h4>Contexts</h4><p>A context is a map which provides information about the state of the world to generators. For instance, a generator might need to know the number of threads which will ask it for operations. It can get that number from the context. Users can add their own values to the context map, which allows two generators to share state. When one generator calls another, it can pass a modified version of the context, which allows us to write generators that, say, run two independent workloads, each with their own concurrency and thread mappings.</p><p>The standard context mappings, which are provided by Jepsen when invoking the top-level generator, and can be expected by every generator, are:</p><pre>:time           The current Jepsen linear time, in nanoseconds<br>  :free-threads   A collection of idle threads which could perform work<br>  :workers        A map of thread identifiers to process identifiers</pre><h4>Transaction generators</h4><p>The MongoDb transactions test suite uses the list-append workload which has the jepsen.tests.cycle.append/gen as the generator. This generator wraps over the elle.list-append/gen generator. The client needs to understand operations of the form:</p><pre>{:type :invoke, :f :txn, :value [[:r 3 nil] [:append 3 2] [:r 3]]}</pre><p>and return completions like:</p><pre>{:type :invoke, :f :txn, :value [[:r 3 [1]] [:append 3 2] [:r 3 [1 2]]]}</pre><p>where the key 3 identifies some list, whose value is initially [1], and becomes [1 2] after an append operation.</p><p>The elle.list-append generator generates operations where values are transactions made up of reads and appends to integer keys.</p><p>The list-append generator i.e append-txns creates wr-txns and replaces the :woperation with :append.</p><p>Example output from the generator</p><pre>(take 10 (la/gen opts))<br>({:type :invoke, :f :txn, :value [[:r 9 nil] [:append 9 1] [:append 9 2] [:r 9 nil]]}<br> {:type :invoke, :f :txn, :value [[:r 9 nil]]}<br> {:type :invoke, :f :txn, :value [[:r 7 nil] [:r 9 nil] [:r 9 nil]]}<br> {:type :invoke, :f :txn, :value [[:append 8 1]]}<br> {:type :invoke, :f :txn, :value [[:append 6 1] [:r 8 nil] [:append 7 1] [:append 9 3]]}<br> {:type :invoke, :f :txn, :value [[:append 9 4]]}<br> {:type :invoke, :f :txn, :value [[:append 9 5]]}<br> {:type :invoke, :f :txn, :value [[:r 9 nil] [:r 6 nil] [:r 9 nil]]}<br> {:type :invoke, :f :txn, :value [[:r 9 nil] [:append 8 2]]}<br> {:type :invoke, :f :txn, :value [[:append 8 3] [:r 9 nil]]})</pre><p>wr-txns generates a lazy seq of transactions where each is of the form</p><pre>{:type :invoke, :f :txn, :value [[:r 9 nil] [:w 8 2]]}</pre><p>The length of the txn is controlled by the max-txn-length and min-txn-length keys.</p><p>Every write is also unique per key meaning if 1 is written for key 5, it is never written again for key 5. This is ensured by using a state variable where there is a current value assoc’d with each key.</p><p>Keys appear in the transactions based on key-distribution type. It can either be uniform meaning each key has same probability of appearing, or exponential which means that key i in the current key pool is k^i times more likely than the first key to be chosen. k is the base, defaults to 2</p><h3>Nemesis</h3><p>jepsen.nemesis/Nemesis is the main protocol which represents a way to introduce faults into the tests.</p><pre>(defprotocol Nemesis<br>  (setup! [this test] &quot;Set up the nemesis to work with the cluster. Returns the<br>                      nemesis ready to be invoked&quot;)<br>  (invoke! [this test op] &quot;Apply an operation to the nemesis, which alters the<br>                          cluster.&quot;)<br>  (teardown! [this test] &quot;Tear down the nemesis when work is complete&quot;))</pre><p>Important functions are bisect, complete-grudge and bridge which distribute given nodes into subsets which are then operated upon by functions like partitioner to create network partitions.</p><p>Network manipulation occurs via the jepsen.net/Net protocol. Out of the box implementations are available for iptables and ipfilter Default is iptables.</p><p>The compose function can combine nemesis and distribute them based on the :op. For example,</p><pre>(compose {#{:start :stop} (partition-random-halves)<br>                #{:kill}        (process-killer)})</pre><p>This routes :kill ops to process killer, and :start/:stop to the partitioner.</p><p>node-start-stopper is an interesting function which takes a targeting function, which selects the node or subset of nodes to act on, a start! function which says what to do when nemesis receives :start and a stop! function which says what to do when nemesis receives :stop.</p><p>Example usage of this function is the hammer-time nemesis which pauses the given process on a node using SIGSTOP, and then resumes it using SIGCONT.</p><pre>(node-start-stopper targeter ;; by default this is rand-nth<br>                    (fn start [t n]<br>                      (c/su (c/exec :killall :-s &quot;STOP&quot; process))<br>                      [:paused process])<br>                    (fn stop [t n]<br>                      (c/su (c/exec :killall :-s &quot;CONT&quot; process))<br>                      [:resumed process]))</pre><h4>Nemesis packages</h4><p>jepsen.nemesis.combined/nemesis-package creates a nemesis map from given options.</p><p>This map has a nemesis, generator for it’s ops and a final-generator to clean up failure modes at the end of the tests and perf for showing test performance graphs.</p><p>This is a generic nemesis which includes partitioning errors, clock-based errors and db errors (start, stop, kill, pause etc) This nemesis package can be used as the first thing to try and then see what kind of errors need more drilling down.</p><p>Every sub-package i.e partition-package, clock-package and db-package is also a map with similar information i.e nemesis, generator, final-generator and perf</p><p>db-nemesis is the basic reify&#39;d class which responds to :start :stop :pause :resumecommands and uses the relevant methods from the DB protocol to implement those operations.</p><p>There is something called node-specs which is used everywhere. This is just a set of keywords which identifies which subset of the nodes to operate on in the nemesis world.</p><ul><li>nil — Chooses a random, non-empty subset of nodes</li><li>:one — Chooses a single random node</li><li>:minority — Chooses a random minority of nodes</li><li>:majority — Chooses a random majority of nodes</li><li>:primaries — A random nonempty subset of nodes which we think are primaries</li><li>:all — All nodes [“a”, …] — The specified nodes</li></ul><h3>Consistency checkers : Elle</h3><p><em>this section consists of my notes taken from an </em><a href="https://www.youtube.com/watch?v=OPJ_IcdSqig"><em>excellent talk</em></a><em> by Kyle Kingsbury where he explains Elle</em></p><p><a href="https://github.com/jepsen-io/elle">Elle</a> is transactional consistency checker for Databases i.e a tool for verifying whether DBs are serializable, snapshot isolated etc.</p><p>Serializability doesn’t say anything about time at which transactions happen, only that there should be some order of txns. So checking for serializability is similar to an ordering problem. Trivially, we can enumerate every possible ordering and eliminate the ones which don’t match our observed reads and writes. But this approach scales at n! so this is bad.</p><p>Serializability can be decomposed into 3 properties (according to a paper on which <a href="https://github.com/aphyr/gretchen">Gretchen</a> is based).</p><ul><li>Internal : inside each transaction, you should observe values consistent with prior reads and writes</li><li>External : you need to see the values which a previous transaction wrote</li><li>Total visibility : order of txns should be a total order, cant be partial</li></ul><p>For external, we need to build a dependency graph of transactions. If i read a value 3, i know it has come from some txn that wrote 3. But if 2 txns write the same value, its difficult to build dependency. If you find a cycle in the dependency graph, there is no total order so serializability is violated.</p><p>Elle is based on <a href="http://pmg.csail.mit.edu/papers/icde00.pdf">this paper</a> by Adya, Liskov, &amp; O’Neil titled <em>Generalized Isolation Level Definitions</em>.</p><p>This paper describes database isolation levels in terms of dependency graphs and cycles.</p><h4>Types of dependency</h4><p>write-read : T1 w(xi) &amp; T2 r(xi) then T2 has to come later as it observed a value T1 wrote</p><p>write-write : T1 w(xi) &amp; T2 w(xj) then T2 has to come later as xi &lt;&lt; xj in version history, which essentially means that if we see values 2 and 3 in an incrementing counter, we know 3 is a later value so it happened later. This is a-priori knowledge</p><p>read-write : T1 r(xi) &amp; T2 w(xj) then T2 has to come later since T2 wrote a later version of x. known as anti-dependency</p><p>From this we can create a direct serialization graph comprising of wr, ww and rw edges and solve for cycles. Nodes are txns.</p><p>Lets say we have histories of operations</p><pre>T1 : w(x1) w(y1)<br>T2 : r(x1) w(y2)</pre><p>But we are missing relations between y1 and y2 and also, we are not sure whether the x1 that we read can only have been written by T1. * If y1 &lt; y2, this is serializable, T1 → T2</p><ul><li>If y2 &lt; y1, there is a cycle and hence not serializable</li></ul><h4>Recoverability</h4><p>If we can look at a value xi and go back to find the only txn which could have written xi, we have recovered it from history. Another problem is that we just write with a value to a register, it replaces the current value and hence destroys history of operations. So if we write xk, we cant be sure that there were previous versions with xj and xi before it.</p><h4>Traceability</h4><p>If we read a value xk, we can trace it back to a write of xk and also a write of xj before and xi before that Types of registers which we can use</p><ul><li>Simple write, if register contains 3 and we write 5, it gets replaced</li><li>Incrementing counter, if register contains 3 and we write 5, it gets added to become 8</li><li>Set, if register contains #{1, 2} and we write 5, it gets added to set to become #{1,2,5} This is useful to infer that we ever read the set and see a value of 5, we are sure that at least one write of 5 has happened prior (but we assume unique writes)</li><li>Append-only list, if register contains [1, 2] and we write 3, if becomes [1, 2, 3] and we can also infer that w2 happened just before this and w1 before that since the register maintains order</li></ul><p>Traceability is similar to audit trails, or oplogs in that sense.</p><p><strong>Example</strong></p><p>Imagine we are given 2 txns</p><pre>T1 : w(x, 1) w(y, 1)<br>T2 : w(x, 2) w(y, 2)</pre><p>This in itself isn’t helpful, but if we add a third txn which reads the 2 registers</p><pre>T3 : r(x, [1,2]) r(y, [2,1])</pre><p>We see that T1 has ww dependency on T2 for x and T2 has ww dependency on T1 for y which forms a cycle. This is a dirty write anamoly !</p><p>So how does it all work ?</p><ul><li>Generate and execute a whole bunch of transactions</li><li>Find wr, ww, rw edges in them by observing the values read and written and build a graph out of them</li><li>Use a specialised linear time algorithm to find strongly connected components (fancy speak for cycles) in the graph. Each of these is an anomaly</li><li>Now if we want to check other types of isolation levels, we can add more constraints (edges) in the graph. For example, add an edge from each txn from same process to check process order</li><li>We can also add edges for real time (single clock of truth) order and check for strict serializability of strong snapshot isolation</li></ul><h3>Conclusion</h3><p>Hopefully this 2 part series of blogs has given you a slightly more in-depth and hands-on view of the amazing work by the Jepsen team ! I would encourage every distributed systems learner to learn and understand the toolkit. It has really helped me understand the such <a href="http://jepsen.io/analyses/mongodb-4.2.6">analyses</a> more clearly and make more learned choices about the databases that we rely upon so heavily in our day jobs !</p><p><em>Originally published on my [tech blog](</em><a href="https://rhishikesh.com/posts/understanding_the_jepsen_toolkit/">https://rhishikesh.com/posts/understanding_the_jepsen_toolkit/</a><em>)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae332260d9b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Jepsen toolkit]]></title>
            <link>https://rhishikeshj.medium.com/understanding-the-jepsen-toolkit-ba733fdab786?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba733fdab786</guid>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[helpshift]]></category>
            <category><![CDATA[clojure]]></category>
            <category><![CDATA[jepsen]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Tue, 06 Apr 2021 08:50:25 GMT</pubDate>
            <atom:updated>2021-04-06T08:50:25.323Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p><a href="http://jepsen.io/">Jepsen</a> is a suite of open-source testing tools aimed at verifying the safety of Distributed systems like databases, queues and consensus implementations. Jepsen also includes a series of amazing <a href="http://www.ustream.tv/recorded/61443262">conference talks</a> and <a href="https://aphyr.com/tags/jepsen">blog posts</a> which offer keen insights into the correctness of such systems under effects of faults like network partitions, split brains etc. To find such errors in the distributed systems, Jepsen uses something known as consistency models to ensure that observed effects of operations are consistent with a given model.</p><h3>What is a consistency model ?</h3><p><a href="http://jepsen.io/consistency#fundamental-concepts">This</a> gives a very good overview of all the important concepts that formulate a consistency model. Briefly put, a consistency model is a set of allowed <strong>operation and result</strong> sequences, also known as a history. It can tell us if an observed sequence of operations and its results are agreeing to a model or are violating it.</p><p>Consider the ++ operation in a language like C. A consistency model for this operation would probably look like subset of integers in increasing order. Like so,</p><p>#{[1 2 3 4 5 6 7] [4 5 6 7 8 9] [0 1 2 3 4 5 6 7] [-7 -6 -5 -4...]},</p><p>which means that if we apply the ++ operation to a variable, we should see incrementally increasing integers. Now if we run this operation on a variable from multiple threads and we observe values like [1 2 1 2 3], this tells us that our code is not consistent with the ++ model.</p><h3>Motivations</h3><p>This blog post, <em>and hopefully a part 2!</em>, aims to explain some of the details of what a Jepsen test looks like, how it actually works and how you may extend it for testing your own Distributed system ! Hopefully this understanding will also enable you to make more sense of the results explained in blog posts like <a href="http://jepsen.io/analyses/mongodb-4.2.6">these</a> and take educated decisions on default configurations and expected behaviors.</p><p>Why did I decide to explore this ? Because I wanted to run such analyses locally and play around with the test-cases. There were a couple of important factors why running these tests locally was important : 1. We <a href="https://twitter.com/helpshifteng">@HelpshiftEng</a> were looking to incorporate multi-document ACID transactions with MongoDB and wanted to understand what behaviors we could expect about correctness. 2. The version of MongoDB that we were targeting was older than the one used in Jepsen’s analyses and also it used a sharded setup whereas we are using a replica-set setup. 3. As a student of distributed systems, this kind of work is very interesting to me and I hoped to learn more about the nature of such systems, <em>which I certainly did!</em></p><p><strong>References</strong> <a href="https://github.com/jepsen-io">Github page</a> <a href="https://github.com/jepsen-io/jepsen/blob/main/doc/tutorial/index.md">Official tutorial</a></p><h3>Design overview</h3><p>Every Jepsen test runs on a system of connected nodes. The main driver of the test is a Clojure program running on a control node. Other nodes in the systems represent the db nodes i.e nodes running the system under test. The test driver performs setup for all the db nodes, including OS related configurations and version management of the db.</p><p>Once a test starts, the control node spins up a set of logically single-threaded processes, each with its own client for the distributed system. A generator generates new operations for each process to perform. Processes then apply those operations to the system using their clients. The start and end of each operation is recorded in a history. While performing operations, a special nemesis process introduces faults into the system--also scheduled by the generator.</p><p>Finally, the DB and OS are torn down. Jepsen uses a checker to analyze the test’s history for correctness, and to generate reports, graphs, etc.</p><p>Let’s get into some details on the components described above!</p><h3>What is a Jepsen test</h3><p>A Jepsen test is essentially a map with some pre-defined keys which are required by the test runner. The jepsen.cli namespace has some APIs like cli/single-test-cmd which can take a test-fn. The test-fn function should return a map with the test information that Jepsen needs.</p><p>Typically such a test map consists of the following keys :</p><pre>;; noop-test<br>{:nodes     [&quot;n1&quot; &quot;n2&quot; &quot;n3&quot; &quot;n4&quot; &quot;n5&quot;]<br> :name      &quot;noop&quot;<br> :os        os/noop ;; implementation of the os/OS protocol, represents the operating system<br> :db        db/noop ;; implementation of the db/DB protocol, represents the database to configure / test<br> :net       net/iptables<br> :remote    control/ssh<br> :client    client/noop ;;  implementation of the client/Client protocol<br> :nemesis   nemesis/noop ;; an implementation or combination of nemesis/Nemesis protocol<br> :generator nil ;; a generator which creates stream of operations which are processed by clients and applied to the DB<br> :checker   (checker/unbridled-optimism) ;; implementation of the checker/Check protocol,<br>                                         ;; verifies that the history of generated operations is valid<br> }</pre><p>Every test map derives from the jepsen.tests/noop-test.</p><h3>Major components of the test</h3><p><strong>os</strong></p><p>jepsen.os/OS protocol contains functionality for operating system setup and teardown. It has the following functions</p><pre>(setup! [os test node])<br>(teardown! [os test node])</pre><p><strong>db</strong></p><p>jepsen.db/DB protocol encapsulates code for setting up and tearing down a database, queue, or other distributed system we want to test. * This protocol specifies two functions that all databases must support: (setup! db test node) and (teardown! db test node)</p><p><strong>net</strong> jepsent.net/Net protocol contains the functions for manipulating the network between the different DB nodes. If has the following functions</p><pre>(drop! [net test src dest])<br>(heal! [net test])<br>(slow! [net test]<br>       [net test opts])<br>(flaky! [net test])<br>(fast! [net test])</pre><p><strong>client</strong></p><p>jepsen.client/Client is the protocol which represents a client for accessing the database. It has the following functions.</p><pre>(open! [this test node])<br>(setup! [this test])<br>(invoke! [_ test op])<br>(teardown! [this test])<br>(close! [_ test])</pre><p>A Jepsen client takes invocation operations and applies them to the system being tested, returning corresponding completion operations, meaning we can define ops like read, write etc in terms of maps for example</p><pre>(defn r   [_ _] {:type :invoke, :f :read, :value nil})<br>(defn w   [_ _] {:type :invoke, :f :write, :value (rand-int 5)})</pre><p>These are functions that construct Jepsen operations: an abstract representation of things you can do to a database. :invoke means that we&#39;re going to try an operation--when it completes, we&#39;ll use a type like :ok or :fail to tell the system what happened. The :f tells us what function we&#39;re applying to the database--for instance, that we want to perform a read or a write. These can be any values--Jepsen doesn&#39;t know what they mean. These ops are passed to the invoke! function in the client where we have to write code for what it means to execute these operations.</p><p><strong>generator</strong></p><p>Generators are functions which generate a stream of operations which are then processed by the clients. For example, a generator like the one below, generates a mix of read and write operations, scheduled every 1 second, with no nemesis and runs for 15 seconds.</p><pre>{:generator (-&gt;&gt; (gen/mix [r w])<br>                 (gen/stagger 1)<br>                 (gen/nemesis nil)<br>                 (gen/time-limit 15))}</pre><p><strong>nemesis</strong></p><p>The nemesis is a special client, not bound to any particular node, which introduces failure across the cluster. The jepsen.nemesis namespace provides several built-in failure modes.</p><p>Like regular clients, the nemesis also draws operations from the generator.</p><p>A nemesis generator which depends on the :start and :stop commands to do introduce faults in the system (like a network partition) can look like</p><pre>(gen/nemesis<br>  (cycle [(gen/sleep 5)<br>    {:type :info, :f :start}<br>    (gen/sleep 5)<br>    {:type :info, :f :stop}]))</pre><p><strong>checker</strong></p><p>To analyze the history, we specify a :checker for the test, and provide a :model to specify how the system should behave. checker/linearizable uses the Knossos linearizability checker to verify that every operation appears to take place atomically between its invocation and completion. We can use checker/compose to compose multiple checkers together.</p><p>Jepsen uses a model to represent the abstract behavior of a system, and a checker to verify whether the history conforms to that model. knossos.model is the commonly used repository of models, jepsen.checker is used as the checker. A model is something that understands the same operations that our client understands (read, write etc). A model data type will take a model state and an operation to apply and return the new model resulting from that operation.</p><p><strong>References</strong> <a href="https://github.com/jepsen-io/jepsen/blob/main/doc/tutorial/index.md">Official Tutorial</a></p><h3>What is a Jepsen test-suite</h3><p>A test suite is created using functions in the jepsen.cli namespace, mainly single-test-cmdand test-all-cmd. Both functions take a map with :test-fn or :tests-fn and :opt-spec keys and return a map with 2 keys in it :test and :analyze which are treated as subcommands by the cli/run! function.</p><ul><li>test subcommand has info on how to run a test including a :run key which is a function to run the test. Each test is run by calling (jepsen/run! (test-fn options)) and checking the results→valid? key of the data returned by run!</li><li>analyze subcommand has info on how to analyze the results of the test. This also has a :run function which runs the jepsen/analyze! function on the test results.</li><li>This :run function takes the test map from the test-fn function, combines it with the data stored for the latest run of the test. This is stored as file in the <strong>store</strong> dir.</li><li>All test results can be obtained by the store/tests function which reads files as Delay objects.</li><li>test-all-cmd works similarly except that it takes a sequence of test maps and returns only the :test-all subcommand.</li><li>The test-all-cmd cant be used in isolation without the single-test-cmd but there won&#39;t be an analyze subcommand.</li><li>cli/run! is the function which runs every subcommand. It takes the map of subcommands to command spec maps, then the command to run and any additional arguments. So when we run lein run test-all , test-all is passed as the second argument to the run!function.</li><li>Each subcommand map has [opt-spec opt-fn usage run] keys in it.</li></ul><h3>How is a Jepsen test run</h3><p>Each test within a suite is represented by a subcommand and needs to have a :run function defined. This function generally invokes the jepsen/run! function with the output of the test-fn function.</p><p>Each test then proceeds as follows,</p><ul><li>Setup the operating system</li><li>Try to teardown, then setup the database</li><li>— — If the DB supports the jepsen.db/Primary protocol, also perform the Primary setup on the first node.</li><li>Create the nemesis</li><li>Fork the client into one client for each node</li><li>Fork a thread for each client, each of which requests operations from the generator until the generator returns nil</li><li>— — Each operation is appended to the operation history</li><li>— — The client executes the operation and returns a vector of history elements which are appended to the operation history</li><li>Capture log files</li><li>Teardown the database</li><li>Teardown the operating system</li><li>— — When the generator is finished, invoke the checker with the history. This generates the final report</li></ul><h3>Dataflow in a test</h3><p>As we saw earlier, a generator is a function which generates a series of operations for the clients.</p><p>Each operation is just a map with the following general shape</p><pre>{:type :invoke/:info/:ok/:fail<br> :f &lt;any keyword that your client understands&gt;<br> :value &lt;value needed by client to process the function&gt;}</pre><p>Each test will have one client implementation along with one nemesis implementation. Both have an invoke! function which takes the test info and an op like the one described above.</p><p>The client is responsible for interpreting the type, f and value keys and take appropriate actions. The results of the actions are supposed to be assoc&#39;d into the op and returned back.</p><p>For example, if a DB client encounters an op like {:type :invoke :f :write :value (rand-int 5)} it could interpret this as a write operation with the value received in the value key.</p><p>Or if a nemesis received an op like {:type :info :f :kill :value nil} it could interpret this as a directive to kill the DB instance on each node.</p><p>The actual code to invoke the generator starts from the jepsen.core/run-case! function which interprets the generator in the interpreter/run! function.</p><p>Once all the ops are generated and passed through the client and nemesis, they are appended to the history for analysis.</p><h3>Running the Jepsen test suites locally</h3><p><em>For official instructions, refer to </em><a href="https://github.com/jepsen-io/jepsen#setting-up-a-jepsen-environment"><em>these documents</em></a></p><p>In my efforts to understand the Jepsen test suite, I ran the <a href="https://github.com/jepsen-io/mongodb">MongoDB</a> tests with a docker setup. Here are the instructions that finally worked for me !</p><ol><li>Follow the instructions <a href="https://github.com/jepsen-io/jepsen/tree/main/docker">here</a> to get the docker cluster running</li><li>Once you have it running, shut it down and modify the jepsen/docker/docker-compose.yml file to add 2 additional nodes. Running these tests require more than 6 MongodDB nodes to be running. You can add 2 more using code snippet below</li></ol><pre>services:<br>  control:<br>    container_name: jepsen-control<br>    hostname: control<br>    depends_on:<br>      - n1<br>      - n2<br>      - n3<br>      - n4<br>      - n5<br>+     - n6<br>+     - n7</pre><pre>...<br>...<br># Add these lines<br>  n6:<br>    &lt;&lt; : *default-node<br>    container_name: jepsen-n6<br>    hostname: n6<br>  n7:<br>    &lt;&lt; : *default-node<br>    container_name: jepsen-n7<br>    hostname: n7</pre><ol><li>It also helps to mount the source code at an accessible location from within the control node. For that, do this</li></ol><pre>services:<br>  control:<br>    container_name: jepsen-control<br>    ...<br>    ...<br>    networks:<br>      - jepsen<br>+   volumes:<br>+     - &quot;&lt;path-from-this-dir-to-mongodb-repo&gt;:/usr/share/code:rw&quot;</pre><ol><li>Start the cluster again.</li><li>SSH into the control node and create a nodes file at an accessible location. The home folder is just fine. Add this to the nodes file</li></ol><pre>n1<br>n2<br>n3<br>n4<br>n5<br>n6<br>n7</pre><ol><li>Navigate into the mounted location where you have this repository. If you have followed the above instructions it should be /usr/share/code. Run the tests using below command</li></ol><pre>lein run test-all -w list-append --nodes-file ~/nodes-file -r 1000 --concurrency 3n --time-limit 120 \<br>--max-writes-per-key 128 --read-concern majority \<br>--write-concern majority --txn-read-concern snapshot --txn-write-concern majority \<br>--nemesis-interval 1 --nemesis partition --test-count 1</pre><p>At the time when I was trying this out, the default mongodb tests from Jepsen actually did not work out of the box on Docker. So I had to make a <a href="https://github.com/rhishikeshj/mongodb/commits/master">few changes</a>. Post that, Aphyr has made some updates to the original code and hopefully the tests will work out of the box for you !</p><h3>Conclusion</h3><p>Hopefully this blog has given you a basic understanding of what a Jepsen tests entails. In the <a href="https://medium.com/posts/understanding_the_jepsen_toolkit_part2/">second part</a> in this series, we will dive slightly deeper into the major components like Generators, Nemesis and Consistency checkers that we have briefly described here.</p><p><em>Originally published on my [tech blog](</em><a href="https://rhishikesh.com/posts/understanding_the_jepsen_toolkit/">https://rhishikesh.com/posts/understanding_the_jepsen_toolkit/</a><em>)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba733fdab786" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Damsel in distress]]></title>
            <link>https://medium.com/impatient-procrastinator/damsel-in-distress-640576a0eef4?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/640576a0eef4</guid>
            <category><![CDATA[fiction]]></category>
            <category><![CDATA[thriller]]></category>
            <category><![CDATA[ghosts]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 17:41:59 GMT</pubDate>
            <atom:updated>2017-10-23T17:41:59.786Z</atom:updated>
            <content:encoded><![CDATA[<p>It was friday I think, I don’t really remember. Yeah it was friday. It was booze night and i had a few too many that day. I was high as a bird ! It was around 1 in the morning and I was returning home when I saw her. I probably shouldn’t have stopped but she looked like a real mess. I figured I ought to help her. It was the booze clouding my judgement. So I did stop. And here’s what happened because I did …</p><p>I walked up to her to ask what the problem was. She was just standing there in the middle of nowhere late at night. It was a dangerous place to be. Her clothes were all dirty and I noticed that there was a spot of red on the t-shirt too. “What is the matter ? What are you doing here so late at night ?” She didn’t respond. May be she didn’t want to talk to anyone. Maybe she was just too scared. I asked again. “What happened ? Can i help you ?” “Shut up ! Just shut up. Don’t try and get into what you don’t understand. You don’t have the balls to even comprehend what the matter is. Let alone help me” Shit. That was out of the blue. Try to help someone and you get this. But I didn’t leave. Any sane man would have but after an entire bottle of antiquity, I wasn’t really very sane. “Please miss, let me help you. You look like you’re in trouble…” . “Trouble !? I am not the one in trouble. It’s him you should be helping really. If I have my way, he is going to be in a shitload of trouble” “What ? what are you talking about ? Who is he ? What are planning to do ?”</p><p>She went quiet. Maybe she had said too much. I was also too jolted to say anything. What was this lady talking about ? What was the horrible thing she was going to do if she had ‘her way’ ? She looked like a normal girl really. Sharp features, short crop of hair, tall. She was tall, and beautiful. God! She was beautiful. Maybe that’s what made me stop to help her. Her face was radiant. And she looked confident. That troubled me more. Something seemed amiss. She wasn’t the damsel in distress she should have been. She looked like someone on a mission. Focussed. And maybe what she just said was the reason. The mission. So I asked again. “What is the problem miss ?Why are you here ? Don’t u have a home you need to go to ?” And that’s when I saw it. A tear rolling down her eyes. Home. Did something bad happen to her home ? Probably someone robbed it. Maybe it was destroyed or something. “ I had a home once. A happy home. Me , my kids and him. It was a good place. A happy place, until that night. I am going to make him pay. I am going to kill him” What ?? What was that women talking about ? Was she out of her mind ? And what was I still doing there. My concerns for her were now long gone and they were replaced by fear. Fear for my own safety. I decided to leave. I didn’t want anything to do with this. Just as I started to go she thundered, “ Where are you going ?! You can’t leave now. If you leave then I wont be able to do what I have planned. I can’t fail, and this time I just can’t want to fail. Twice before I have tried to have my revenge. My rightful revenge. But the bastard escaped. He had luck on his side. This time I won’t fail. Tonight is the end of him. The end of his ghastly existence. He is a demon. A rotten hearted son of a bitch. Killed his own daughter, my daughter….”. By now she was totally broken. “This time I have this, and this time my hand won’t hesitate to slice open his heart and watch till it bleeds out the last drop of vicious poisonous blood in his body”. The blade of the weapon was frighteningly sharp. And it was covered with blood. Maybe it was used before ? Used recently ? Shit… this was bad. I needed to get out of there.</p><p>I tried to run. Just as I turned she caught hold of my throat and brought the knife to my heart. “Where are you going bastard ? Don’t you remember me ?! Don’t you remember your own wife ? Don’t you remember our daughter screaming for her life as you stabbed her 13 times ? Don’t you remember coming up to me with this knife. This very same knife and telling me that you were sorry. That you had no choice but to kill us all lest anybody find out what you had done. I tried to run away. I tried to run for my life. but I failed. The last stab near the heart was just too much“. And then suddenly I remembered. This was Priya, but she was dead wasn’t she. I killed her with my own hands. I killed her with that very knife…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=640576a0eef4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/impatient-procrastinator/damsel-in-distress-640576a0eef4">Damsel in distress</a> was originally published in <a href="https://medium.com/impatient-procrastinator">Impatient Procrastinator</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Second coming]]></title>
            <link>https://medium.com/impatient-procrastinator/second-coming-20b38acfb0ff?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/20b38acfb0ff</guid>
            <category><![CDATA[short-story]]></category>
            <category><![CDATA[fiction]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 17:22:06 GMT</pubDate>
            <atom:updated>2017-10-23T17:22:06.611Z</atom:updated>
            <content:encoded><![CDATA[<p>Dear diary,</p><p>As i write this, i know i am going to die any day now. He is surely going to kill me. I have seen it in his eyes. I have seen the hatred, i have seen the hurt and most importantly, the revenge which seethes his soul.</p><p>As i look back on my life, all i remember is May 26th 1980. That was the day my fate was sealed. As i heard the words “we the jury find the defendant guilty of voluntary manslaughter and arson and hereby sentence him to life imprisonment”, i was almost too calm. I knew what i had done. I wasn’t hopeful of my freedom. I had given up on life a long time ago. I was probably dead inside already. These people will only put a body in prison, the soul is already freed, i thought to myself. I was so wrong.</p><p>The first few years in prison were horrible. They almost made me wish for death. But as the days went by, i grew comfortable with the prison life. It became routine. The constant fear for life, the almost unbearable pain and the humiliation, all became routine. I had found my own set of friends, if you could call them that. One of them was a serial killer, one was a bank robber. Some others were rapists. And i was the arsonist. All in all, it was good bunch of people.</p><p>Then one day, we had guests. New inmates. And as we watched them enter the walls of this hell hole we called home, we could see the eternal hope in their eyes. They still had the fight in them. They were still angry. It will go away soon, just give them a few years. I hadn’t noticed him then. Johnny that is. Not that it would have mattered. He would have found me anyway.</p><p>I met Johnny during one of our construction hours. He was as old as my boy would have been now. Give or take a few years. And there was something about this boy. I couldn’t quite put my finger on it. Maybe he reminded me of my own little boy. No. I shouldn’t think about it, i told myself. But the resemblance was almost too eerie. As time went by, he grew comfortable around us. He was part of our group. He was an intelligent boy, he told us how he had successfully robbed many a bank with his deception and con skills. It was only this one last time, he said, that something went wrong. Maybe someone from the group had ratted or something. He didn’t know, he said. As i look back now, maybe it wasn’t a mistake. Of course it wasn’t. He just wanted to get in here somehow. To put an end to his misery and anger. To finish what i had started 20 years ago.</p><p>As i was taking a shower yesterday, he came to me. “You are here for killing your family isn’t it !?” how did he know that, i though to myself. I hadn’t told anybody about it. I was probably afraid of telling myself of what i had done. “Your wife Melinda and your son Bob, right !? You remember that night don’t you ? You remember how you strangled mom before you slit her throat and watched her die. You remember me crying while i sat next to her lifeless body ? You remember putting fire to the house , your own house ?!”. How could he possibly know that ? It couldn’t be. I was sure i had burned the house and everything inside it down to ashes. How could he have escaped. “Is that you Bobby ?” i asked. “Did you survive that night ?”. “No dad, i couldn’t. I couldn’t escape, i didn’t want to leave mom just by herself. I was scared for her. I wanted to be there by her side.” “Then who are you ? My son is dead isn’t he ?”. “Yes dad, consider this my second coming. And now you will get what you deserve. My revenge will be done.”</p><p>As i write this, i know i am going to die any day now. He is surely going to kill me. I have seen it in his eyes. I have seen the hatred, i have seen the hurt and most importantly, the revenge which seethes his soul.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20b38acfb0ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/impatient-procrastinator/second-coming-20b38acfb0ff">Second coming</a> was originally published in <a href="https://medium.com/impatient-procrastinator">Impatient Procrastinator</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What next ?]]></title>
            <link>https://medium.com/impatient-procrastinator/what-next-f9a1038c54ef?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9a1038c54ef</guid>
            <category><![CDATA[short-story]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 17:21:30 GMT</pubDate>
            <atom:updated>2017-10-23T17:21:30.132Z</atom:updated>
            <content:encoded><![CDATA[<p>It was a typical summers afternoon in a small town in Texas. The heat was unbearable. But he had no choice. He had a job to do. Twenty jobs, to be precise. Doug was a tv repair guy for an electronics store. He was your typical average joe. A hard grind through life, struggling to make ends meet. The only family he had was his mother with whom he lived. But lately, even she was becoming a burden for him. Constantly ill, never happy, always crying and shouting and writhing in the pain of the cancerous disease that afflicted her. He could hardly afford her medicines. Doug hated his life. He was uncomfortable with every aspect of his life. And it was this afternoon that his desperation turned to sadism.</p><p>Doug had first his taste of blood that afternoon. A farmer in Texas whom he beat up to death with a baseball bat. How that farmer must be wishing his TV wasn’t broken that day. But it was something else about that man which triggered Doug’s actions. It reminded him of his own father. An abusive drunken man who abandoned his own family because he just couldn’t handle the responsibility. Abandoned his own son, abandoned his wife who loved him even though he beat her black and blue after every drunken tirade of his. That day, Doug felt strong. He felt empowered. That man deserved to die, he said to himself. And the revenge felt almost like a drug. And he needed more of it.</p><p>That summer, Doug went on to kill twenty five other people. He was almost impeccable with his skills. He left no evidence. No witnesses. Just the baseball bat. That became his signature. The county sheriff was out of his wits trying to find the “baseball bludgeoner “. Doug was busy preparing for his day ahead. He only had five repair jobs today and he had his baseball bat with him.</p><p>Meanwhile, in another part of town, Billy was just about to begin another one of his break-ins. He was a robber. Breaking into peoples houses. Snatching whatever he could before the inhabitants showed up and disappearing into thin air. Typically. But there were also many houses which weren’t so easy, so peaceful. Sometimes the owners showed up too early, and when they saw Billy, they just panicked. Sometimes they tried to fight back. Billy did not like that one bit. He even told them to stop or else. Else he would have to make them stop. Billy was never proud of the people he killed. But if they just would listen. If only they would have let him take everything and leave. They didn’t understand. Billy was hoping he didn’t have to use his gun today. The owners were out. He had seen them leave in their car. Probably on their way to an afternoon lunch and some shopping.</p><p>He broke in. These houses were becoming almost too easy for Billy. Tripping the alarms was a bit tricky, but he had mastered the technique. Billy looked around. This was always an exciting moment for him. Scanning the house for valuables. Picking whatever caught his fancy. He was just about to enter the bedroom when he heard a noise. He heard someone talking. Yes. Someone was in the house. He began rushing towards the bedroom. Just as he entered the room, he saw her. A young girl, barely thirteen, holding a phone in her hand. What did she do ! “Did you just call the police ?” He roared. “You shouldn’t have.” But she was too scared to say anything. Just then he heard the the door open. Did she call her parents ? Billy went into the living to check. And his worst fears came true. There in front of him stood the owners of the house. And the husband was just about to use his phone. The following few moments were like a blur. And when it all ended, Billy was standing there with the gun in his hand, two shells at his foot and just one thought in his head. If only the man had listened to him. Why did he need to call the police. Now his daughter will have to suffer the consequences. She will have to go through life without her parents. And all because her father didn’t listen.<br>Billy was rudely brought out of the shock by the doorbell. Who could it be ? The police ? Did the father manage to call them ? Could it be the neighbors ? Billy was too shocked to be thinking straight. He probably shouldn’t have opened the door. But he did. “Hi ! I am Doug. I am here to repair your Tv. Could I come in ?”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9a1038c54ef" width="1" height="1" alt=""><hr><p><a href="https://medium.com/impatient-procrastinator/what-next-f9a1038c54ef">What next ?</a> was originally published in <a href="https://medium.com/impatient-procrastinator">Impatient Procrastinator</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[And then it hit me…]]></title>
            <link>https://medium.com/impatient-procrastinator/and-then-it-hit-me-15763680b153?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/15763680b153</guid>
            <category><![CDATA[short-story]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 17:18:50 GMT</pubDate>
            <atom:updated>2017-10-23T17:20:00.095Z</atom:updated>
            <content:encoded><![CDATA[<p>I am Jean Bernaad and i am the best tight-rope walker in the world. And as i plummet to my death, i can see the most wonderful rocky valley calling me into its ever wider arms. The valley almost seems a friend. A friend who is longing for me, pulling me towards it, what it doesnt realise is that it might kill me in the process. Not its fault really, its me who has been teasing it, taunting it almost daring it to kill me.<br>It all started a few years ago when a friend of mine, Jose, dared me to try something so dangerous, that is was always fatal ! I was a simple tight-rope walker in the local circus. I loved the job because it gave me a chance to travel and get the daily dose of adventure that i so craved. Although it didnt start out that way, it had become a passion for me by now. I was very good at it ! I could even do the rope walk without the balancing pole and sometimes, even without the safety net ! So when Jose told me about the crazy adventure, i was both scared out of my wits as well as intrigued. “Walk the rope in the Cook mountain valley without any safety nets !!” Jose said. The fear almost apparent in his voice as his face. The first time i tried the crazy stunt is vividly etched in my mind ! The fear was overpowering, and yet my body was completely at ease. Maybe it knew something my mind didnt. After the initial shock, the thrill and the adrenaline rush began to kick in. It was nothing like anything i had experienced in my life !! And once it was over, i was longing for another dose ! Somehow i resisted the temptation. Knowing fully well that one small misstep or a single gust of wind could turn fatal. But i found myself engulfed in the need, the want for adrenaline and adventure was too much and i went back there again and again. Cheating death at every step, taunting the beautiful valley which waits 8000 feet below me.<br>And what a beautiful valley it is. Covered with lush green forests on one side and bare barren unforgiving rock on the other. And clouds for company ! Brilliant, serene clouds ! It is a breathtaking sight if there ever was one. And as i fall into its arms today, my breath will be taken for good !<br>As i rush nearer to the ground, all these thoughts come rushing to my head. The beautiful face of my wife, my angelic daughter Mira ! O ! how i am going to miss them. I can see my parents now. I am probably hallucinating. They look young. Dad was never happy with what i had done in my life, and his grim contempt did nothing to betray his feelings about me. Mom looks calm, calmer than expected actually. I am dieing mom, your son is about to die. Dont you feel any sadness ? Then i realise something, maybe she is happy. Happy that i am coming to her. Finally, I can meet her. My life here never gave me the time, maybe the heavens will. Now i can see myself, my young self that is. I recognise the circus roof immediately. Its my first walk. I look as scared as a bunny. Idiot. Little do i realise that i am so good at this already. I dont need to be afraid. I am a natural on the rope. Balance, poise and concentration. Qualities that have never betrayed me till now.<br>Now. How did i fail today ? What went wrong ? I had performed all the necessary checks. My shoes are perfectly dry, the balancing pole is the same that i have used for so many years. There was no sudden gush of wind, no vibrations on the rope, then what went wrong ? How did i lose my balance ? Trying to remember every step of the way, i am still baffled. Every step, every little movement of every little sinew of my body. I remember seeing my wife standing at the other end. Waiting with bated breath for me to make it to her side. “This would be my last time”, i had promised her that. Then we were going to abandon this dangerous life and settle down to a normal life. I have a daughter now, that changes perspective. She is a princess and i have to take care of her the best i can. But can i really live without this now ? Without the thrill, the constant adrenaline rush. Life is about doing what you love to do, isn’t it. If i cant do what I love to do, want to do, hell, need to do, whats the use of living such a life.</p><p>And then it hit me….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15763680b153" width="1" height="1" alt=""><hr><p><a href="https://medium.com/impatient-procrastinator/and-then-it-hit-me-15763680b153">And then it hit me…</a> was originally published in <a href="https://medium.com/impatient-procrastinator">Impatient Procrastinator</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Retribution]]></title>
            <link>https://medium.com/impatient-procrastinator/retribution-8e5c4f01f195?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e5c4f01f195</guid>
            <category><![CDATA[suspense]]></category>
            <category><![CDATA[short-story]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 17:14:27 GMT</pubDate>
            <atom:updated>2017-10-23T17:15:15.628Z</atom:updated>
            <content:encoded><![CDATA[<p>As he walks slowly, almost trudging towards his house, Vikram realizes something. It was 3 years ago to this day that all of this had started. This was the day everything started going down hill. This was the day that fate decided to deal its cruel hand. The hand was revealed much later, with the calm and composure of a hired assassin; and the kill was almost complete now. This was the day, 3 years ago that his journey had started. A journey towards his ultimate end. Some called it his first day at work, but he preferred to call it ‘the beginning of the end’.</p><p>Work had sucked out almost all of the life from within him. He could hardly recognise the man he saw in the mirror. The man in the mirror was a good for nothing software engineer; a man who had no hobbies, a man who had no interests, a man who had no time to even look for happiness in his life. This was not the man he wanted to be. Far from it. He had high hopes for himself. He wanted to walk a free spirit. Wander the worlds no one wandered, experience the experiences no one experienced and live the life no one ever lived ! God knew what any of it meant, but he was pretty sure this was exactly what he wanted to do.</p><p>But now there was no turning back. No resurrection. The damage was done. The boy who graduated out of college had died and with him died all his wonderful dreams. All that was left was hate and pain and a lot of caffeine.</p><p>The man in the mirror had one more story. Project retribution ! He still wonders what possessed him to come up with such a dastardly plan. Such pure evil. Pure and simple evil. Sometimes when someone is pushed to the brink and then tickled very slightly just so that he jumps over the edge, it really pisses the hell out of him. And then what happens next is, as they say, anybody’s guess. Maybe that’s what happened to Vikram. But this was beyond anybody’s guess. He had made sure of that. He had asked all of the ‘bodies’ he knew, to guess. Nobody could guess what project retribution was. It was pure genius, that’s what it was.</p><p>Every year, a new target was chosen. A lost soul, a misunderstood man, a man who had wronged, a man who had been wronged. And then he was released from his misery. He was released from the pathetic and sad life that he was living, and taken to a better place. A place where there was more joy, more calm and more freedom.</p><p>Ganesh was the third kid that Vikram had helped rehabilitate. Like the previous two, Ganesh too was wasting away the golden days of his life in a juvenile prison. Cornered by the circumstances into doing things he really didn’t completely understand. Doing what he thought was required to survive. And breaking a few laws and some houses in the process. But now he was on the path to resurrection. Ganesh had a particular interest in playing the tabla. Vikram had learnt of this from his early conversations with Ganesh. Vikram had used this passion as a fulcrum on which to base the rehabilitation program. Vikram worked closely with Ganesh for over 6 months. He helped him develop an urge to learn, an urge to become a better person, an urge to live a better life ! And by god’s grace, Ganesh too had responded well to all of Vikram’s efforts. He was now ready to come out of that hell hole and start a new life, turn a new leaf. Vikram was going to be there every step of the way, helping him, guiding him, lifting him should he fall and smiling joyously when he would rise !</p><p>Yet another success for Project Retribution. This was his ultimate revenge ! A life for a life.</p><p>“Everytime you take away a part of my life, I will make sure one life is resurrected.”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e5c4f01f195" width="1" height="1" alt=""><hr><p><a href="https://medium.com/impatient-procrastinator/retribution-8e5c4f01f195">Retribution</a> was originally published in <a href="https://medium.com/impatient-procrastinator">Impatient Procrastinator</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deathrow]]></title>
            <link>https://medium.com/impatient-procrastinator/deathrow-84c322b3742?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/84c322b3742</guid>
            <category><![CDATA[short-story]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Mon, 23 Oct 2017 17:13:58 GMT</pubDate>
            <atom:updated>2017-10-23T17:13:58.138Z</atom:updated>
            <content:encoded><![CDATA[<p>As he poured his daily drink, his favorite jazz record was his only companion. That was all he ever needed actually. At least thats what he had convinced himself of. Sitting in his rickety old armchair, he contemplated what he was about to do. His final act. His final duty.</p><p>Azrael thought about his first day on the job. His first day as an executioner at the state prison. It was a rainy winter afternoon. The murky darkness of the windows seemed to echo the soul of the man standing in front of him. It was a deranged man who had been convicted of killing twenty children in a local school a month ago. And as the man stood in front of Azrael, he wondered to himself who of the two was more terrified of the impending death. He knew it was only his job to kill that man, but somehow he could not bring himself to pull that lever. One switch and the man who be thrown into violent convulsions as his body would be engulfed by the fatal jolts of electricity. He had not slept for three nights after he witnessed his first execution. And he was sure that day he sleep would desert him again for a few days. The violent fury of death had been permanently etched in his mind. And so was the violent fury in the dying man’s eyes.</p><p>The days turned into months and months into years. Azrael had managed to block out any emotional duress he suffered from being around death all of his days. He grew quite accustomed to the perennial presence of pain and suffering around him. He would wake up each morning with a tiny bit of excitement as to what awaited him that day. Not that he would ever even admit to it. Not even to himself. He was too scared to confront that excitement. His hatred towards these demented souls led him to rather enjoy watching them suffer as they writhed to their deaths. Or maybe it was his craving for taking lives that led him to hate these people. Just so that he could justify to himself that what he was doing, what he was enjoying, what he was looking forward to, was not wrong. He was not wrong.</p><p>Azrael thought about death today. He thought about death a lot today. He loved the control he had on the death of so many people. He was the one who decided when they went. He was the one who decided how they went. He was the one with their lives in his hand. His to take, his to end, his to enjoy !</p><p>Today had been his last day on the job. Today had been his last kill. He could no longer go back to it. He could no longer control death as he pleased. And he was missing it already. His hunger just could not be satiated any where else. Death was the only thing he knew to control in his life. Death was the only thing that made him feel alive. He could not let go of his control.</p><p>There was one more life that he had complete control on. One life he could end if he wished, when he wished and how he wished. His own. And that was precisely his plan today. And a wonderful plan it was. The perfect swan song. The perfect ode to his control on death. As he sat in his final resting place, a makeshift electric chair he had himself designed, he was still sipping on his most expensive cognac. He looked at the switch. Took his last sip and threw the glass to the floor. The shattering of the glass was almost like a drum roll, a prelude to his final act. And then he flipped the switch….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84c322b3742" width="1" height="1" alt=""><hr><p><a href="https://medium.com/impatient-procrastinator/deathrow-84c322b3742">Deathrow</a> was originally published in <a href="https://medium.com/impatient-procrastinator">Impatient Procrastinator</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Thief]]></title>
            <link>https://medium.com/impatient-procrastinator/thief-cbaee370af4e?source=rss-40e7baec56c------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbaee370af4e</guid>
            <category><![CDATA[poetry]]></category>
            <category><![CDATA[satire]]></category>
            <dc:creator><![CDATA[Rhishikesh Joshi]]></dc:creator>
            <pubDate>Mon, 02 Jan 2017 04:38:17 GMT</pubDate>
            <atom:updated>2017-01-02T04:38:17.404Z</atom:updated>
            <content:encoded><![CDATA[<p>I am like a thief who is afraid of the dark,<br>of the deathly silence, the gnarly dogs’ bark.</p><p>I scourge for wealth in the day, never venture out in the night,<br>when the darkened souls awaken, ravenous and hungry for a fight.</p><p>They call it a revolution, an uprising, a spring.<br>It is but a war, a heinous mutiny, against our beloved king.</p><p>This too shall pass, to such storms, we leaders do not sway.<br>And when the blinding day comes again, we shall make them pay !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbaee370af4e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/impatient-procrastinator/thief-cbaee370af4e">Thief</a> was originally published in <a href="https://medium.com/impatient-procrastinator">Impatient Procrastinator</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>