<?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 Jon Ackerland on Medium]]></title>
        <description><![CDATA[Stories by Jon Ackerland on Medium]]></description>
        <link>https://medium.com/@jonackerland?source=rss-14d2cd63f8de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fCvNM46JSYSdTRz8kgyI2A.png</url>
            <title>Stories by Jon Ackerland on Medium</title>
            <link>https://medium.com/@jonackerland?source=rss-14d2cd63f8de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 23:31:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jonackerland/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[Top 5 iTerm Features I Rely On]]></title>
            <link>https://medium.com/@jonackerland/top-5-iterm-features-i-rely-on-51be03e25d9?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/51be03e25d9</guid>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[top-5]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[iterm2]]></category>
            <category><![CDATA[tools-for-developers]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Sat, 24 Dec 2022 19:47:58 GMT</pubDate>
            <atom:updated>2022-12-24T19:47:58.194Z</atom:updated>
            <content:encoded><![CDATA[<h3>Top 5 iTerm2 Features I Rely On</h3><p>YALOC2 — Yet Another List Of Crap #2 or a list of (un)common iTerm2 features I use daily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fvXv9iOAM9sQ8HvW" /><figcaption>Photo by <a href="https://unsplash.com/@gamell?utm_source=medium&amp;utm_medium=referral">Joan Gamell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you have not heard of iTerm2 and you work as a software engineer or a DevOp, you must have been living under a rock. You absolutely have to give it a try, it’s probably the best terminal emulator for macOS out there.</p><h3>1. Split Panes</h3><p>Of course you can use tmux — it works on mac as well. But who wants to spend time learning how to use it? Not me, I prefer to get my job done effectively and fast. That’s why I absolutely love that iTerm2 comes with a built-in tmux abstraction and provides a simple and easy to use interface for it. Using multiple panes absolutely boosts my productivity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTS8wBNDBpLkljqb84_aBA.png" /><figcaption>Split panes in all their glory.</figcaption></figure><h3>2. Broadcast Input</h3><p>I find myself regularly working with several split panes at once. For example, each pane is a ssh connection to a different machine. What if I need to run the same command in each of the ssh sessions? Easy peasy if I use the broadcast input feature which allows me to broadcast the keyboard input to all or only select terminals on my screen. Absolutely amazing, especially when working with clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Qc3Y5IFeyB3di7HgBtGKg.png" /><figcaption>Broadcasting input to all panes simultaneously.</figcaption></figure><h3>3. Password Manager</h3><p>“Why on earth do I want to use a password manager built into iTerm2?” That is a legitimate question. Since we’re civilized enough to use unique passwords for each set of credentials we need, we stopped writing them down in notepads and switched over to password managers. So why would anyone want to replace their favorite password manager with the one in iTerm2? It’s not about replacing anything. Have you ever needed to ssh into machines using the same, password protected ssh key? Did copy pasting that password from your favorite password manager to the terminal get old really fast? I am sure it did. If you add this credential to iTerm2’s password manager, you can forget about copy pasting. All you’ll need to do is use a keyboard shortcut to open the password manger in iTerm2, select the credential from a list and hit enter. And if you use split panes and need the same password in multiple panes, no problem, just check the broadcast checkbox. Oh and did I mention it detects if the terminal you’re trying to use the credentials in is not asking you for password and will not display the password in plain text even if you by mistake try to apply it in this case? Yes, it’s pretty sweet, definitely improved my quality of life.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AilAHdak3-PrBhSb9otsNQ.png" /><figcaption>Select that credential and boom … you’re in.</figcaption></figure><h3>4. Search</h3><p>Have you ever worked with a log, long output, a list of processes etc. and tried to find something specific in the output? Probably anyone who’s dealing with computer engineering problems experienced that at some point in their life. An approach to get your task at hand done is to read all the lines and try to find what you’re looking for. But who has the time for that? You can write scripts to filter our data you need and sometimes that’s the way to go. But iTerm2 has a powerful search feature built-in! It even highlights the hits for you and displays how many there are. And it works with anything on the screen from open files to command outputs. Imagine how happy this makes me as a vi user in environments where I am forced to use nano or emacs 😂</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*Eou3fnCdk8VVCLNyqX3w0A.png" /><figcaption>The power of search.</figcaption></figure><h3>5. Instant Replay</h3><p>Have you ever lost the content of the screen and needed to run that long running job for the n-th time? Nothing can be more frustrating than that. Happened to me way to often. Just imagine running a long load test on a virtual server and while documenting the results the VM is lost, logs are gone and your terminal scroll history is not going back far enough. You can rerun the test or use iTerm2’s instant replay to go back in time and see what you used to have on your screen. Time travel iTerm2 style.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lIjxcdULthi6JiUTtgL0nw.png" /><figcaption>Time travel with instant replay.</figcaption></figure><p>Hope you’ll find some of those features just as useful as I do! ◼️</p><p>Jon Ackerland</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51be03e25d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChatGPT Write for Me!]]></title>
            <link>https://medium.com/@jonackerland/chatgpt-write-for-me-e8049f824af9?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8049f824af9</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 03:32:37 GMT</pubDate>
            <atom:updated>2022-12-08T03:32:37.982Z</atom:updated>
            <content:encoded><![CDATA[<p>I let ChatGPT work for me while I sat on my wing chair and sipped on Scotch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KEPEe3Y2_DtlPMeA" /><figcaption>Photo by <a href="https://unsplash.com/@agk42?utm_source=medium&amp;utm_medium=referral">Alex Knight</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>ChatGPT definitely prompted a public reaction and caused a flow of opinions. I decided to test it out, to see what the hype is all about and to share my findings. Obviously I am (also) a writer, so I tested it’s story-writing abilities. What if I can simply offload my work to it? 🤞</p><p>First I asked it to write an article for me: <em>Write an 800 words article about the programming language Python, favorable.</em></p><blockquote>Python is a popular and versatile programming language that is widely used in a variety of fields, including web development, data science, and artificial intelligence. Developed in the late 1980s by Guido van Rossum, Python is known for its simplicity, readability, and versatility.</blockquote><blockquote>One of the key advantages of Python is its clear and concise syntax. Unlike many other programming languages, Python uses simple, English-like keywords and phrases, making it easy to read and understand even for beginners. This clarity makes it a great choice for those new to programming, as well as for experienced developers looking to quickly prototype and test new ideas.</blockquote><blockquote>Another key strength of Python is its large and active community. Python has a thriving ecosystem of libraries and frameworks that make it easy to tackle a wide range of tasks, from data analysis and machine learning to web development and automation. The community also regularly releases new updates and improvements to the language, ensuring that Python stays at the forefront of technological advancement.</blockquote><blockquote>Python is also highly versatile, making it a good choice for a wide range of projects. It is used extensively in data science and machine learning, thanks to its powerful numerical and scientific computing capabilities and the availability of specialized libraries such as NumPy and Pandas. It is also popular in web development, with frameworks such as Django and Flask making it easy to create complex, dynamic websites. Additionally, Python can be used for automation and scripting, as well as for creating standalone applications.</blockquote><blockquote>One of the reasons for Python’s popularity is its ease of use. Unlike many other programming languages, Python does not require the use of complex syntax or strict rules for coding, making it accessible to a wide range of users. It also has a simple and straightforward learning curve, allowing beginners to quickly get up to speed and start writing their own programs.</blockquote><blockquote>Despite its simplicity, Python is a powerful language that is capable of tackling complex tasks. It has a rich set of built-in data types and standard libraries that make it easy to manipulate and analyze data, as well as to perform mathematical and scientific computations. It also supports object-oriented, procedural, and functional programming paradigms, giving developers the flexibility to choose the right approach for their project.</blockquote><blockquote>In recent years, Python has gained significant traction in the field of artificial intelligence and machine learning. Its powerful numerical and scientific computing capabilities, as well as the availability of specialized libraries such as TensorFlow and PyTorch, make it a popular choice for developing AI and machine learning models. Python is also used in natural language processing and computer vision, as well as for building intelligent chatbots and other AI-powered applications.</blockquote><blockquote>Overall, Python is a versatile and powerful programming language that is well-suited for a wide range of tasks. Its simplicity, readability, and versatility make it a great choice for beginners and experienced developers alike. Its thriving community and extensive ecosystem of libraries and frameworks make it easy to tackle complex projects, and its popularity in fields such as data science and artificial intelligence make it a valuable skill to have in today’s job market.</blockquote><p>I must admit reading this almost knocked my socks off 🤯. I did not expect an AI generating content reaching that quality. It is logically structured, non-repetitive and it even follows the pattern of introduction, body and conclusion.</p><p>Let’s try something cultural now: <em>What is the impact of Bob Dylan on modern music?</em></p><blockquote>Bob Dylan is a legendary musician and songwriter who has had a profound impact on modern music. His unique blend of folk, rock, and blues, combined with his socially and politically charged lyrics, have influenced countless artists and helped to shape the sound and direction of popular music.</blockquote><blockquote>Dylan’s impact can be seen in a variety of musical genres, from folk and rock to hip hop and country. Many artists have cited Dylan as a major influence on their own work, and his songs have been covered by a wide range of artists, including Jimi Hendrix, The Byrds, and Guns N’ Roses.</blockquote><blockquote>One of the key ways in which Dylan has influenced modern music is through his lyrics. Dylan’s songs often deal with complex and challenging themes, such as politics, social justice, and personal relationships. His ability to express deep emotions and complex ideas in a simple and relatable way has inspired many artists to push the boundaries of their own songwriting and explore new ideas and themes in their own work.</blockquote><blockquote>Additionally, Dylan’s unique vocal style and use of unconventional techniques, such as his distinctive nasal twang and his use of non-standard guitar tunings, have also had a lasting impact on modern music. Many artists have cited Dylan as an important influence on their own vocal and guitar styles, and his innovations have helped to pave the way for new sounds and techniques in popular music.</blockquote><blockquote>In conclusion, Bob Dylan’s impact on modern music is undeniable. His unique blend of folk, rock, and blues, combined with his socially and politically charged lyrics, have influenced countless artists and helped to shape the sound and direction of popular music. His innovations and influence can be seen in a wide range of genres and styles, and he remains a beloved and influential figure in the world of music.</blockquote><p>This time it did not really hit the point precisely, but it spat out those 300 words for free and it did it quicker than I can say “Bob Dylan” out loud. Definitely enough for a student’s homework or even Dylan’s description for the music app I am developing.</p><p>At last, let’s try: <em>How to deal with stress on the workplace?</em></p><blockquote>Dealing with stress in the workplace can be challenging, but there are a few steps you can take to manage it effectively.</blockquote><blockquote>First, it’s important to recognize the signs of stress and take them seriously. These can include physical symptoms such as headaches, stomach aches, and fatigue, as well as emotional symptoms such as irritability, anxiety, and loss of motivation. If you notice these symptoms, it’s important to take a step back and assess the situation.</blockquote><blockquote>Next, try to identify the causes of your stress. This can include things like unrealistic deadlines, conflicts with coworkers, or excessive workload. Once you know what is causing your stress, you can take steps to address it. For example, if you are feeling overwhelmed by your workload, you could try to prioritize your tasks, delegate some work to others, or talk to your manager about adjusting your deadlines.</blockquote><blockquote>It’s also important to take care of yourself and prioritize your own well-being. This can include making time for physical activity, getting enough sleep, and eating a healthy diet. It can also help to practice relaxation techniques such as deep breathing or meditation. These can help to reduce stress and improve your overall mental health.</blockquote><blockquote>Finally, don’t be afraid to seek help if you need it. This could mean talking to a therapist, counselor, or other mental health professional, or reaching out to supportive friends or family members. These people can provide valuable support and guidance as you navigate the challenges of dealing with stress in the workplace.</blockquote><blockquote>Overall, managing stress in the workplace requires a combination of self-awareness, effective coping strategies, and support from others. By recognizing the signs of stress, identifying its causes, and taking steps to address them, you can reduce your stress levels and improve your overall well-being.</blockquote><p>Even though a bit generic, this could already pass as an legitimate article in some publications. After a short introduction of the subject, it provided a few pieces of advice and concluded with a brief summary of suggestions. Well done, ChatGPT!</p><p>I let ChatGPT write for me today. Even though I am surprised by the quality of the output, I do not think it can substitute a human writer (not yet at least). It cannot relate feelings, opinions, make judgement calls or provide personal aspects. We enjoy reading (and some of us writing) that, though. So, although technically it can already write for me, it can’t write for me.</p><p>What do you think of ChatGPT’s writing skills? Please, feel free to leave a comment! ◼️</p><p>Jon Ackerland</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8049f824af9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Not Yet Another List!]]></title>
            <link>https://medium.com/@jonackerland/top-5-xy-613b75bda5a1?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/613b75bda5a1</guid>
            <category><![CDATA[llifestyle]]></category>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[top-5]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[satire]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Sat, 03 Dec 2022 06:49:56 GMT</pubDate>
            <atom:updated>2022-12-04T04:20:32.046Z</atom:updated>
            <content:encoded><![CDATA[<p>Why are top n lists so popular?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B0p2JvQgkM6BSbxz" /><figcaption>Photo by <a href="https://unsplash.com/@wizwow?utm_source=medium&amp;utm_medium=referral">Donald Giannatti</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Top 5 sites that teach you 4 years of collage education in 3 minutes! Top 18 tools to increase your productivity by 700%. Top 7 beauty secrets, that will make you look like a superstar. Top 24 things to do before you die.</p><p>And the list goes on and on. Why are those trashy articles so popular?</p><h3>Lie baby, lie!</h3><p>We all like to read lies, from fairy tales to top XY lists. It just feels so good! Admittedly these articles may at times introduce us to something useful, however most of the time they are a time waster and garbage at best. But we keep on reading them, buying the lie, wanting to believe. “ The next one will be different, useful, educational”, we keep on lying to ourselves. And then we click and click and believe and believe.</p><h3>Hit me hard, hit me fast!</h3><p>What’s your attention span? How would your estimate? Let me tell you something, whatever you think it is, it’s probably magnitudes shorter than you imagine. Modern research shows it’s 8.25 seconds! That is shorter than the attention span of a goldfish (9 seconds)! Top XY articles present a short list of whatever the subject may be. Most of the time, 8 seconds is more than enough to get the gist of it and move on to the next “Top 19 ways on how to earn six figure salary in 3 days”. And there are so many of them too, feels like being a child in a candy shop, only now you can try them all! Hit me!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WC5AoI-ezZZr_pPR" /><figcaption>Photo by <a href="https://unsplash.com/@kyawthutun?utm_source=medium&amp;utm_medium=referral">Kyaw Tun</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Glutton for delusion</h3><p>Fast pacing life requires a lot of us. Being constantly on the move, holding our head above the water, multitasking, jumping, dodging, running — all at once, no time to catch a breath. We need fast solutions, there’s no time to waste. Top XY articles offer a phantasy of giving us something useful without any effort on our part. They introduce us to something we haven’t heard of before and we get the impression it’s actually good and that it will improve our life. 8 seconds later we forget about it anyways, but the satisfaction kicks in and we want some more!</p><h3>Top 5 ways to stop reading lists</h3><p>Are you ready for this? Yet another list, but this one is different, it’ll ACTUALLY help you stop reading list articles and use your time for something more productive.</p><ol><li><strong>Cook</strong>; recipes include lists of ingredients — redirect your need to get a list in for something delicious!</li><li><strong>Go to gym</strong>; a workout routine includes a list of exercises-healthy!</li><li><strong>Watch commercials</strong> — it’s equally useless as reading lists, but it’s not reading lists.</li><li><strong>Read tweets</strong> — tweets are a great substitute for lists, short, sorted by time … almost like a list! Ah, wait … Twitter is falling apart … never mind.</li><li><strong>Read the local train schedule</strong> — basically a list, but unlike the list articles this may actually prove to be useful some day.</li></ol><p>◼️</p><p>Jon Ackerland</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=613b75bda5a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 5 Hacking Sites]]></title>
            <link>https://medium.com/@jonackerland/top-5-hacking-sites-7686fe7edde6?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/7686fe7edde6</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[lists]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[cryptography]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Sat, 03 Dec 2022 05:50:28 GMT</pubDate>
            <atom:updated>2022-12-03T05:50:28.939Z</atom:updated>
            <content:encoded><![CDATA[<p>Ever wanted to learn how to hack?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QMn_Z0Y9inmhpUie" /><figcaption>Photo by <a href="https://unsplash.com/@nahelabdlhadi?utm_source=medium&amp;utm_medium=referral">Nahel Abdul Hadi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>1. HackTheBox</h3><p>“A massive hacking playground”. Competitions, playgrounds, hands on penetration testing, hacking training, etc. This site has some high quality materials and is an absolute must if you want to learn cyber security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*998vkYoRulg_W5R3v_vwLQ.png" /></figure><p><a href="https://www.hackthebox.com/">Cyber Mastery: Community Inspired. Enterprise Trusted. | Hack The Box</a></p><h3>2. OpenSecurityTraining</h3><p>An amazing collection of training materials of various levels, from beginner, intermediate to the advanced classes. Materials are organized in a form of curriculums, many of them accompanied with videos, slides and written materials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gsy-IwhIpSnHAlF53c3l6w.png" /></figure><p><a href="https://opensecuritytraining.info/Welcome.html">Welcome</a></p><h3>3. Phrack</h3><p>A legendary hacking zine. It’s impact on the hacking community is proverbial and it simply has to be in your resource repertoire. White papers are written by hackers for hackers and of the highest quality. Ever heard of the article “Smashing the stack for fun and profit”? It first appeared in this very zine!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I8yUDwH-K5uoD2RuaO-Dww.jpeg" /></figure><p><a href="http://www.phrack.org/">.:: Phrack Magazine ::.</a></p><h3>4. CNIT 127: Exploit Development</h3><p>A full class with videos and slides, based on the book “The Shellcoder’s Handbook: Discovering and Exploiting Security Holes&quot;. The class is thought and prepared by Sam Bowne. The lectures and materials are of an exceptionally high quality and guide you through “The Shellcoder’s Handbook” chapter by chapter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGJIXkQhYg7qU3CJjSj1Ww.png" /></figure><p><a href="https://samsclass.info/127/127_F18.shtml#schedule">https://samsclass.info/127/127_F18.shtml</a></p><h3>5. Cryptopals</h3><p>Hands-on challenges focused on cryptography. Implement various encryption and decryption algorithms, break them, have fun with them, play with them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8b3s_31_t1WRuFZ-Sya3Q.png" /></figure><p><a href="https://cryptopals.com/">The Cryptopals Crypto Challenges</a></p><p>Happy hacking! ◼️</p><p>Jon Ackerland</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7686fe7edde6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implicit Relations Anti-Pattern]]></title>
            <link>https://medium.com/@jonackerland/implicit-relations-anti-pattern-c92874cec7ee?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/c92874cec7ee</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding-practice]]></category>
            <category><![CDATA[antipattern]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Wed, 30 Nov 2022 04:48:23 GMT</pubDate>
            <atom:updated>2022-11-30T04:48:23.787Z</atom:updated>
            <content:encoded><![CDATA[<p>When relations in the code exist exclusively in someone else’s head</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UF-xRyncdEmug3BO" /><figcaption>Photo by <a href="https://unsplash.com/@nate_dumlao?utm_source=medium&amp;utm_medium=referral">Nathan Dumlao</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever read a part of code and could not figure out where a function, a variable, perhaps a config is coming from? After spending a lot of time searching and mind stretching, you realized there is absolutely nothing in the code that tells you where what you are looking for is defined. I hope you did not have such experience, but if you did, welcome to the club! Chances are you’ve been introduced to the implicit relations anti-pattern.</p><h3>Manifestation</h3><p>If you’re not in the club yet, you may wonder what this is all about. Imagine two git repositories. One features your application code and a configuration file. The other features IaC for your application. So far so good, right? However, the code from the IaC repository modifies the config from your application repository on deployment and there is no indication in the application repository that that’s how things work. Even worse, imagine code in a third repository, which also makes changes to your application configuration file!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0jWkXUZNVEDdn_na" /><figcaption>Photo by <a href="https://unsplash.com/@ryansnaadt?utm_source=medium&amp;utm_medium=referral">Ryan Snaadt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>How to avoid it?</h3><h4>Single Responsibility Principle</h4><p>If you decide to split your code base in multiple repositories, that’s fine, but keep things separate. Follow single responsibility principle and do not mix e.g. application and infrastructure code (if that’s how you’ll split things). Make sure the boundaries are clear and everyone is on the same page as to what goes where.</p><h4>Mono-Repository</h4><p>Keeping things together and not separating them is another option, perhaps even more obvious than separation. If your application is small, then this is probably the best way to go. And even if it is not that small, carefully think about the possibility of keeping things together before dismissing it as an viable option.</p><h4>Git Submodules</h4><p>The advantage of this solution is that it behaves like a mono-repository, even though the code in reality resides in two or more repositories. For this to be effective, single responsibility principle must be followed when deciding on separation. But it might make development a bit easier, since you can pull code from all repositories into a central spot and work on it as if it would be a mono-repository. The disadvantage of this approach is that git submodules are not the easiest to work with.</p><h4>Strict Naming Convention</h4><p>This is not really a solution, but let’s suppose you cannot use any of the above mentioned suggestions. At least — as a bare minimum — a consistent naming convention can indicate where what is defined or inherited from. Use the name of the git repository as part of the configuration. Think of the example we mentioned in the beginning, one repository with a config file and application code and the second repository with IaC, which modifies configuration in the application’s config. In this case you could name the placeholders in the configuration file like in the example below.</p><pre>{<br>  “maxProcesses”: “{{iac-repo.maxProcesses}}”<br>}</pre><p><em>iac-repo </em>is the name of the IaC repository which will set the value on runtime. Of course, this approach has several disadvantages. What if you decide to rename IaC repository or split IaC codebase into more repositories, etc. Also, the approach is hard to enforce and depends mostly on developers.</p><p>As with any journey, not only the destination, but also how you get there are important, especially if you’re going to use the same paths more than once. Therefore, do everyone a favor and pave the roads for them instead of keeping them in your head! ◼️</p><p>Jon Ackerland</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XQ6_TJMAMoR0d1ql" /><figcaption>Photo by <a href="https://unsplash.com/es/@les_photos_de_raph?utm_source=medium&amp;utm_medium=referral">Raphaël Biscaldi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c92874cec7ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MySql Transaction Isolation Levels]]></title>
            <link>https://medium.com/@jonackerland/mysql-transaction-isolation-levels-2876b0d8302d?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/2876b0d8302d</guid>
            <category><![CDATA[transaction-isolation]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[transactions]]></category>
            <category><![CDATA[database-optimization]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Sun, 27 Nov 2022 17:10:25 GMT</pubDate>
            <atom:updated>2022-11-27T17:10:25.875Z</atom:updated>
            <content:encoded><![CDATA[<p>What are transaction isolation levels and how do they differ in practice?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dK9LYDnsYE9I_5ns" /><figcaption>Photo by <a href="https://unsplash.com/@andrewshelley?utm_source=medium&amp;utm_medium=referral">Andrew Shelley</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently we had to analyze the transaction isolation level in use on a system I work on and I realized that this is quite an interesting topic to dig into. Like many other database engines, MySql too offers ANSI (American National Standards Institute) compatible transaction isolation levels. What are they and what are the problems they solve? In which circumstances should a certain transaction isolation level be used? In this article we’ll go first through some of the theory and then start experimenting with transaction isolation levels using MySql.</p><h3>Isolation</h3><p>MySql is an ACID compliant database engine. ACID stands for Atomicity, Consistency, <strong>I</strong>solation and Durability. In essence, ACID is a set of properties of database transactions intended to guarantee data validity despite errors, power outages, failures etc.</p><p>Keeping the transactions isolated from each other simply means that they will not affect one another. At the highest transaction isolation level a running transactions will not be interfered by another transaction that is running concurrently with it. Other transaction isolation levels offer less isolation and as a consequence of interference a transaction might face a read phenomenon.</p><h3>Read Phenomena</h3><p>First, we need to understand what the transaction isolation levels are protecting us against. Therefore, let’s describe read phenomena that may happen in concurrent transactions.</p><h4>Dirty Read</h4><p>Occurs when a transaction reads data written by another uncommitted transaction. Dirty read is quite a problem, since we do not know if the transaction which modified the data that was read is going to be committed in the end or rolled back. In case of a rollback, we would end up with incorrect data in the transaction.</p><h4>Non-Repeatable Read</h4><p>In this case a transaction reads the same row twice and gets different results for each read, because a parallel, committed transaction modified the data between the two reads.</p><h4>Phantom Read</h4><p>Is similar to non-repeatable read, but instead of a single row the phenomenon affects a set of rows. In this case a transaction re-executes a query that returns rows matching a condition and sees a different set of rows being returned than in the initial read. This happens, because a parallel transaction changed (modified or deleted) and committed the data.</p><h4>Serialization Anomaly</h4><p>The result of a group of concurrent committed transactions is impossible to achieve if we try to run them sequentially in any order without overlapping.</p><h3>Transaction Isolation Levels</h3><p>ANSI defines 4 standard transaction isolation levels. MySql supports all 4. Below is a list of them from the lowest to the highest level.</p><h4>Read Uncommitted</h4><p>In this transaction isolation level reads from uncommitted transactions are possible and thus dirty reads can happen.</p><h4>Read Committed</h4><p>Only reads from committed transactions are possible. Because of that dirty reads are prevented. However, non-repeatable read and phantom read can still happen.</p><h4>Repeatable Read</h4><p>Ensures that the same query will always return the same result. Even if other transactions changed the rows that satisfy the query. It prevents dirty read, non-repeatable read and phantom read.</p><h4>Serializable</h4><p>The highest transaction isolation level. Guarantees that concurrent transactions will be able to yield the same result as if they would be executed in a certain order, one after another, without overlapping. This isolation level prevents all read phenomena.</p><h3>Experiments</h3><p>How can I know which isolation level is currently in use? As usual in MySql, there are 2 variables that define it. One refers to the setting of the current session and the other is the global isolation level set in the config. All sessions will use what is set in global unless it’s explicitly overridden in the session. The isolation level of the current session can be retrieved by querying <em>@@transaction_isolation</em> and for the global setting <em>@@global.transaction_isolation</em>. By default MySql uses repeatable read.</p><pre>&gt; select @@transaction_isolation;<br>+-------------------------+<br>| @@transaction_isolation |<br>+-------------------------+<br>| REPEATABLE-READ         |<br>+-------------------------+<br><br>&gt; select @@global.transaction_isolation;<br>+--------------------------------+<br>| @@global.transaction_isolation |<br>+--------------------------------+<br>| REPEATABLE-READ                |<br>+--------------------------------+</pre><p>To modify session isolation level, use SET SESSION TRANSACTION ISOLATION LEVEL statement. It will modify only the isolation level of the current session, global isolation level will remain unchanged.</p><pre>&gt; set session transaction isolation level read uncommitted;<br>Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select @@transaction_isolation;<br>+-------------------------+<br>| @@transaction_isolation |<br>+-------------------------+<br>| READ-UNCOMMITTED        |<br>+-------------------------+<br><br>&gt; select @@global.transaction_isolation;<br>+--------------------------------+<br>| @@global.transaction_isolation |<br>+--------------------------------+<br>| REPEATABLE-READ                |<br>+--------------------------------+</pre><p>In all experiments a simple table <em>ledger</em> will be used:</p><pre>&gt; select * from ledger;<br>+----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+<br>|  1 | George |     100 | USD      | 2022-11-26 15:39:48 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>|  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>+----+--------+---------+----------+---------------------+</pre><h4>Read Uncommitted</h4><p>Open 2 separate MySql sessions, set the isolation level in both to read uncommitted and start a transaction in both sessions. In transaction 1 subtract $10 from George’s balance. What happens with George’s balance in transaction 2? Even though transaction 1 was not committed yet, transaction 2 already sees the modified value $90.</p><pre>&gt; set session transaction isolation level read uncommitted;         &gt; set session transaction isolation level read uncommitted;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; start transaction;                                                &gt; start transaction;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select * from ledger;                                             &gt; select * from ledger; <br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |          | id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>|  1 | George |     100 | USD      | 2022-11-26 15:39:48 |          |  1 | George |     100 | USD      | 2022-11-26 15:39:48 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |          |  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>|  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |          |  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br><br>&gt; update ledger set balance = balance - 10 where id = 1;<br>Query OK, 1 row affected (0.00 sec)<br><br>&gt; select * from ledger;                                             &gt; select * from ledger; <br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |          | id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>|  1 | George |      90 | USD      | 2022-11-26 15:39:48 |          |  1 | George |      90 | USD      | 2022-11-26 15:39:48 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |          |  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>|  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |          |  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br><br>&gt; commit;                                                           &gt; commit;<br>Query OK, 0 rows affected (0.01 sec)                                Query OK, 0 rows affected (0.01 sec)</pre><p>What we experience in transaction 2 is dirty read phenomenon and it happens because we are using read uncommitted isolation level.</p><h4>Read Committed</h4><p>Open 2 MySql sessions, set the isolation level in both to read committed and then start a transaction in each. Subtract $10 from George’s balance in transaction 1. If we select our ledger table in transaction 2, we see that George’s balance was not modified. This is because transaction 1 was not committed yet and we are using read committed isolation, which prevents our transaction from seeing uncommitted changes from other transactions. This prevents dirty read phenomenon that we experienced in read uncommitted isolation level.</p><pre>&gt; set session transaction isolation level read committed;           &gt; set session transaction isolation level read committed;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; begin;                                                            &gt; begin;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select * from ledger;                                             &gt; select * from ledger;<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |          | id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>|  1 | George |      90 | USD      | 2022-11-26 17:01:00 |          |  1 | George |      90 | USD      | 2022-11-26 17:01:00 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |          |  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>|  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |          |  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br><br>&gt; update ledger set balance = balance - 10 where id = 1;<br>Query OK, 1 row affected (0.00 sec)<br><br>&gt; select * from ledger;                                             &gt; select * from ledger where id = 1;<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |          | id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>|  1 | George |      80 | USD      | 2022-11-26 17:21:49 |          |  1 | George |      90 | USD      | 2022-11-26 17:01:00 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |          +----+--------+---------+----------+---------------------+<br>|  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>+----+--------+---------+----------+---------------------+</pre><p>Are non-repeatable read and phantom read also prevented? Let’s continue with the experiment. We left off with George’s balance being $80 in transaction 1 and $90 in transaction 2. This is because transaction 1 has not been committed yet and read committed isolation prevents transaction 2 from seeing uncommitted results from transaction 1. If we commit transaction 1 and lookup George’s balance in transaction 2 again, we will see it changes to $80. The phenomenon at hand is called non-repeatable read, since the same query that we already ran now returns a different value.</p><pre>                                                                    &gt; select * from ledger where balance &gt;= 90;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  1 | George |      90 | USD      | 2022-11-26 17:01:00 |<br>                                                                    |  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>                                                                    |  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>                                                                    +----+--------+---------+----------+---------------------+<br><br>                                                                    &gt; select * from ledger where id = 1 ;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  1 | George |      90 | USD      | 2022-11-26 17:01:00 |<br>                                                                    +----+--------+---------+----------+---------------------+<br><br>mysql&gt; commit;<br>Query OK, 0 rows affected (0.00 sec)<br><br>                                                                    &gt; select * from ledger where id = 1;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  1 | George |      80 | USD      | 2022-11-26 23:03:48 |<br>                                                                    +----+--------+---------+----------+---------------------+<br></pre><p>If we rerun the query to display all rows with balance of $90 or more, we will not see George’s balance in the result anymore — instead of returning 3 rows, the query returns only 2. In this case the same query returns a different set of rows. This is called phantom read phenomenon.</p><pre>                                                                    &gt; select * from ledger where balance &gt;= 90;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>                                                                    |  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>                                                                    +----+--------+---------+----------+---------------------+</pre><p>What we learn from this experiment is that read committed isolation prevents dirty read, but does not prevent non-repeatable read nor phantom read. The experiment also helps us understand how non-repeatable read and phantom read manifest themselves in practice.</p><h4>Repeatable Read</h4><p>Start 2 sessions again, set both to repeatable read isolation level and start a transaction in each session. Lower George’s balance by $10 in transaction 1. George’s balance is $70 after the change. We know dirty read has been prevented in read committed isolation level already, so it will not happen here again, therefore we do not need to verify it. Instead, commit transaction 1.</p><p>What happens with George’s balance in transaction 2? If we run a query in transaction 2, we see George’s balance is still $80, it was not decreased to $70 even though transaction 1 is already committed. That’s because repeatable read isolation level ensures all read queries are repeatable. Which means it always returns the same result even if there are changes committed in other transactions. As a result non-repeatable read is prevented.</p><pre>&gt; set session transaction isolation level repeatable read;          &gt; set session transaction isolation level repeatable read;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select @@transaction_isolation;                                   &gt; select @@transaction_isolation;<br>+-------------------------+                                         +-------------------------+<br>| @@transaction_isolation |                                         | @@transaction_isolation |<br>+-------------------------+                                         +-------------------------+<br>| REPEATABLE-READ         |                                         | REPEATABLE-READ         |<br>+-------------------------+                                         +-------------------------+<br><br>&gt; begin;                                                            &gt; begin;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select * from ledger;                                             &gt; select * from ledger where id = 1;<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |          | id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>|  1 | George |      80 | USD      | 2022-11-26 23:03:48 |          |  1 | George |      80 | USD      | 2022-11-26 23:03:48 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |          +----+--------+---------+----------+---------------------+<br>|  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>+----+--------+---------+----------+---------------------+              <br>                                                                    &gt; select * from ledger where balance &gt;= 80;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  1 | George |      80 | USD      | 2022-11-26 23:03:48 |<br>                                                                    |  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>                                                                    |  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>                                                                    +----+--------+---------+----------+---------------------+<br><br>&gt; update ledger set balance = balance - 10 where id = 1;<br>Query OK, 1 row affected (0.00 sec)<br><br>&gt; select * from ledger;<br>+----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+<br>|  1 | George |      70 | USD      | 2022-11-26 23:53:45 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>|  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>+----+--------+---------+----------+---------------------+<br><br>&gt; commit;<br>Query OK, 0 rows affected (0.01 sec)<br><br>                                                                    &gt; select * from ledger where id = 1;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  1 | George |      80 | USD      | 2022-11-26 23:03:48 |<br>                                                                    +----+--------+---------+----------+---------------------+</pre><p>What about phantom read? Let’s query all rows with balance of $80 or more. The result includes all three rows. This means phantom read is prevented as well.</p><pre>                                                                    &gt; select * from ledger where balance &gt;= 80;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  1 | George |      80 | USD      | 2022-11-26 23:03:48 |<br>                                                                    |  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>                                                                    |  3 | Pat    |     500 | USD      | 2022-11-26 15:40:08 |<br>                                                                    +----+--------+---------+----------+---------------------+</pre><p>What happens if we subtract $10 from George’s balance in transaction 2? Does the balance change to $70, $60 or does MySql raise an error?</p><pre>                                                                    &gt; update ledger set balance = balance - 10 where id = 1;<br>                                                                    Query OK, 1 row affected (0.00 sec)<br>                                                                    Rows matched: 1  Changed: 1  Warnings: 0<br><br>                                                                    &gt; select * from ledger where id = 1;<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    | id | name   | balance | currency | timestamp           |<br>                                                                    +----+--------+---------+----------+---------------------+<br>                                                                    |  1 | George |      60 | USD      | 2022-11-27 00:15:16 |<br>                                                                    +----+--------+---------+----------+---------------------+<br><br>                                                                    &gt; rollback;<br>                                                                    Query OK, 0 rows affected (0.00 sec)</pre><p>The update did not throw an error and George’s balance is $60! This is the correct value, since transaction 1 already committed a change that lowered George’s balance to $70. However, from transaction 2 point of view the math does not add up. Based on the last select query, it would be expected a subtract by $10 results in $70. This proves that transaction 2 is still being interfered by updates from concurrent transactions.</p><p>The observed behavior when modifying George’s balance in transaction 2 is MySql specific. Some other database engines, like for example PostgreSQL, raise errors in situations like these, to ensure the consistency of the data in the transaction.</p><p>Before moving on to the next isolation level rollback transaction 2.</p><h4>Serializable</h4><p>Start 2 separate MySql sessions, set the session transaction level in both to serializable and start a transaction in each. Query all rows of the ledger table in transaction 1 and George’s balance in transaction 2. Results of those queries are expected and are not interesting. Subtract $10 from George’s balance in transaction 1. Interestingly the update is blocked. What is happening is that the query in transaction 2 is blocking the query in transaction 1. If the query in transaction 1 does not get unblocked, it will eventually timeout and throw an error.</p><pre>&gt; set session transaction isolation level serializable;             &gt; set session transaction isolation level serializable;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select @@transaction_isolation;                                   &gt; select @@transaction_isolation;<br>+-------------------------+                                         +-------------------------+<br>| @@transaction_isolation |                                         | @@transaction_isolation |<br>+-------------------------+                                         +-------------------------+<br>| SERIALIZABLE            |                                         | SERIALIZABLE            |<br>+-------------------------+                                         +-------------------------+<br><br>&gt; begin;                                                            &gt; begin;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br><br>&gt; select * from ledger;                                             &gt; select * from ledger where id = 1;<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |          | id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>|  1 | George |      70 | USD      | 2022-11-26 23:53:45 |          |  1 | George |      70 | USD      | 2022-11-26 23:53:45 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |          +----+--------+---------+----------+---------------------+<br>|  3 | Pat    |     500 | USD      | 2022-11-27 00:13:50 |<br>+----+--------+---------+----------+---------------------+<br><br>&gt; update ledger set balance = balance - 10 where id = 1;<br>ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting <br>transaction</pre><p>The reason for this behavior is that in serializable isolation level MySql implicitly converts all plain SELECT queries to SELECT … FOR SHARE statements and a transaction that holds SELECT … FOR SHARE only allows other transactions to SELECT the rows, but not UPDATE or DELETE them. This mechanism prevents the inconsistency between transactions, which we ran into in the repeatable read isolation level.</p><p>As mentioned, the lock eventually times out. Therefore, if transaction 2 does not commit or rollback and so release the lock before the time out in transaction 1, we get a lock timeout exceeded error. If this happens, we must retry the transaction. This means that if serializable isolation level is in use, a transaction retry strategy has to be implemented by the application.</p><p>In the next experiment, retry transaction 1 and keep transaction 2 as is. Subtract George’s balance by $10 in transaction 1 and do the same in transaction 2 before update query in transaction 1 times out. What happens?</p><pre>&gt; begin;<br>Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select * from ledger;<br>+----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+<br>|  1 | George |      70 | USD      | 2022-11-26 23:53:45 |<br>|  2 | John   |     200 | USD      | 2022-11-26 15:39:57 |<br>|  3 | Pat    |     500 | USD      | 2022-11-27 00:13:50 |<br>+----+--------+---------+----------+---------------------+<br><br>&gt; update ledger set balance = balance - 10 where id = 1;<br><br>                                                                    &gt; update ledger set balance = balance - 10 where id = 1;<br>                                                                    ERROR 1213 (40001): Deadlock found when trying to get lock; try restarting transaction<br><br>Query OK, 1 row affected (2.19 sec) <br>Rows matched: 1  Changed: 1  Warnings: 0</pre><p>A deadlock in transaction 2 occurs. Because now transaction 2 also has to wait on the lock from the query in transaction 1. So, besides lock timeouts, deadlocks also need to be handled by the application in case of serializable isolation level.</p><p>Before moving on, rollback both transactions and restart them. Run a query to display George’s account in both transactions. Subtract $10 from George’s balance in transaction 1 and commit transaction 2. We see that the lock in transaction 1 is released immediately after commit in transaction 2 and George’s balance in transaction 1 is updated.</p><pre>&gt; rollback;                                                         &gt; rollback;<br>Query OK, 0 rows affected (0.01 sec)                                Query OK, 0 rows affected (0.01 sec)<br><br>&gt; begin;                                                            &gt; begin;<br>Query OK, 0 rows affected (0.00 sec)                                Query OK, 0 rows affected (0.00 sec)<br><br>&gt; select * from ledger where id = 1;                                &gt; select * from ledger where id = 1;<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |          | id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br>|  1 | George |      70 | USD      | 2022-11-26 23:53:45 |          |  1 | George |      70 | USD      | 2022-11-26 23:53:45 |<br>+----+--------+---------+----------+---------------------+          +----+--------+---------+----------+---------------------+<br><br>&gt; update ledger set balance = balance - 10 where id = 1;<br><br>                                                                    &gt; commit;<br>                                                                    Query OK, 0 rows affected (0.00 sec)<br><br>Query OK, 1 row affected (8.05 sec)<br>Rows matched: 1  Changed: 1  Warnings: 0<br><br>&gt; select * from ledger where id = 1;<br>+----+--------+---------+----------+---------------------+<br>| id | name   | balance | currency | timestamp           |<br>+----+--------+---------+----------+---------------------+<br>|  1 | George |      60 | USD      | 2022-11-27 00:53:12 |<br>+----+--------+---------+----------+---------------------+<br>1 row in set (0.00 sec)</pre><p>We learn that serializable prevents all read phenomena: dirty read, non-repeatable read, phantom read and serialization anomaly. However, it comes with some tradeoffs: locks and deadlocks. An application using this isolation level must implement transaction retry strategy as well as deadlock handling.</p><p>Table 1 sums up read phenomena observed. It shows on which isolation level they occur and on which they are prevented.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*DVtwxLDcDGvoYa2ouwVy4w.png" /><figcaption>Table 1: Transaction isolation levels in relation to read phenomena</figcaption></figure><h3>Which transaction isolation level should I use?</h3><p>After getting a good understanding of the differences between isolation levels and read phenomena, we learn that there is no silver bullet, it all depends on the needs of the application. That being said, repeatable read is the default transaction isolation level in MySql and is suitable for most use cases.</p><p>Of course needs vary. If you’re building a banking application, you might want to prevent serialization anomaly, therefore serializable will be your pick. On the other hand you might want to use read committed isolation level, since it eliminates blocking and might perform better.</p><p>If you are considering choosing a certain transaction isolation level with the only goal of improving performance of your application in mind, make sure you test thoroughly. On a system I work on, we went from read committed to repeatable read and the capacity tests showed improvements in the responsiveness of the system, except in the highest 10% of the maximum load. With other words, the application performed slightly worse after we passed load that is 10% under the absolute breaking point. Since the absolute breaking point was already so high, that we do not think we will reach it in real life, its reduction by 10% does not present a problem. However, by moving to repeatable read we benefited greatly by the elimination of the non-repeatable read and phantom read phenomena.</p><h3>Conclusion</h3><p>Transaction isolation levels affect the isolation property of transactions. As we learned through experimentation, different levels prevent different read phenomena and consequentially may affect transactional data consistency. MySql defaults to repeatable read, which is the most suitable for majority of applications, however different needs call for different tools. Therefore, it is always good to be armed with knowledge that helps to choose the most suitable tool for the job. ◼️</p><p>Jon Ackerland</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2876b0d8302d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 5 Tools I Install on my Mac]]></title>
            <link>https://medium.com/@jonackerland/top-5-tools-i-install-on-my-mac-a0fea75c5cb6?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0fea75c5cb6</guid>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[terminal]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[tools-for-developers]]></category>
            <category><![CDATA[top-5]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Sun, 20 Nov 2022 01:52:40 GMT</pubDate>
            <atom:updated>2022-11-22T03:18:28.614Z</atom:updated>
            <content:encoded><![CDATA[<p>YALOC — Yet Another List Of Crap or a list of exotic tools I can’t live without.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W4WFzG1tNuhru-Gn" /><figcaption>Photo by <a href="https://unsplash.com/@nina_mercado?utm_source=medium&amp;utm_medium=referral">Nina Mercado</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Everyone is listing their fav XY whatever. Surprise, surprise so will I! 🤯</p><h3>1. Oh My Zsh</h3><p>Oh My Zsh is an amazing framework for managing zsh. It comes with large variety of tools, scripts, themes, helpers, plugins, etc. I simply can’t use my shell without it anymore.</p><figure><img alt="Terminal with Oh My Zsh" src="https://cdn-images-1.medium.com/max/1024/1*eengQ14nOmRAqmIgqCMGPw.png" /><figcaption>Oh My Zsh in action.</figcaption></figure><h3>2. z</h3><p>z??? Have you ever been tired of typing in whole paths when changing directories in a terminal? Well, I have. With z, which is a plugin for zsh, I can easily navigate just by using something similar to the snippet below:</p><pre>z my-dir</pre><p>z keeps track of the full paths for me and finds them when needed. Therefore it knows ‘my-dir’ is in ‘/home/jon/top-secret-projects/nsa-classified-5/top-secret/my-dir’. See, all I need to remember is just the top directory name and that’s it!</p><figure><img alt="z demo" src="https://cdn-images-1.medium.com/max/1024/1*kE3qZDiLyREwIBY4C5slxQ.png" /><figcaption>Jumping directories with z.</figcaption></figure><h3>3. FiraCode</h3><p>FiraCode is a beautiful font. Not only it is appealing to the eye, it also is utmost readable and clear and it even supports ligatures. Some might argue a font is not a tool, but I beg to differ. Software engineers spend a ton of hours reading and writing code. If a font that won’t make your eyes bleed and prevent you from performing self-enucleation is not a tool, then what is?</p><figure><img alt="FiraCode code snippet" src="https://cdn-images-1.medium.com/max/1024/1*fOnpqL5OYp_E4mIwT3xI9w.png" /><figcaption>FiraCode — so beautiful, readable and clear.</figcaption></figure><h3>4. ssh-agent</h3><p>Are you using SSH access to you git repository with password protected private SSH keys? If so (and I surely hope you do), then you know that entering the password of the private key after every git push, pull, fetch etc. becomes old quite fast. ssh-agent saves the unlocked key for the duration of the terminal session. Thus, no password prompts anymore — without lowering the security by removing password protection of the private key.</p><figure><img alt="ssh-add -l command" src="https://cdn-images-1.medium.com/max/790/1*s6SGTFTbWnH_DvKRh2uefg.png" /><figcaption>List with SSH keys added to ssh-agent.</figcaption></figure><h3>5. gopass</h3><p>I use KeePass as the password management and secure storage at work as well as personally. gopass is a read-only KeePass terminal client, written in go (obviously). What I love with this thing is, that it allows me to open several KeePass files at once and then work on all of them at once, without needing to switch from one file to another. It even supports a config file, where I can set the paths to all my KeePass files and it will open them on init for me, so that I do not need to remember and type them in (by now you know how much I hate remembering paths). It makes work with KeePass stores a breeze!</p><figure><img alt="Snippet with gopass in action" src="https://cdn-images-1.medium.com/max/760/1*_283Tyg2UZ25QbaWHrqiIw.png" /><figcaption>Intuitive and easy to use KeePass client.</figcaption></figure><p>Well, there they are — 5 exotics I fully rely on every day. Give them a try, perhaps you’ll find them useful too! ◼️</p><p>Jon Ackerland</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0fea75c5cb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is there such thing as a conf.d pattern?]]></title>
            <link>https://medium.com/@jonackerland/is-there-such-thing-as-a-conf-d-pattern-d66fddeb9bab?source=rss-14d2cd63f8de------2</link>
            <guid isPermaLink="false">https://medium.com/p/d66fddeb9bab</guid>
            <category><![CDATA[corporate-language]]></category>
            <category><![CDATA[observation]]></category>
            <category><![CDATA[language]]></category>
            <category><![CDATA[column]]></category>
            <category><![CDATA[corporate-culture]]></category>
            <dc:creator><![CDATA[Jon Ackerland]]></dc:creator>
            <pubDate>Sat, 19 Nov 2022 03:12:05 GMT</pubDate>
            <atom:updated>2023-08-16T13:20:40.444Z</atom:updated>
            <content:encoded><![CDATA[<p>Meaningless gibberish or facts?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WB4wPtQEFmOns2qp" /><figcaption>Photo by <a href="https://unsplash.com/@huntersrace?utm_source=medium&amp;utm_medium=referral">Hunters Race</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recently I was in a meeting in which a colleague was trying to convince us he is using a conf.d pattern. In reality the configuration file he wrote just simply used an include statement. Of course naming something a “pattern” does sound educated and gives the architecture at hand a verbal implication of solidness and reliability. But as software engineers we know that using cliches like “pattern” at the meetings, we may fool the management, but we can’t avoid the technical consequences — which will catch up — regardless of the nomenclature.</p><p>But why are we facing this phenomena? The experience from above is far from being an isolated case. Catchy phrases and overused words are a constant in the corporate world. Management loves them, hungry employees too. Every time AWS comes out with a new product, its name must come up at the next meeting. This conveys an impression of keeping the pace with the changing times, an impression of not lacking behind and of still riding the wave. But is it that simple?</p><p>How long did it take for the web to become device friendly? The answer might cause a depression. When I bought my HP iPAQ 111 in the mid 2000s — Web 2.0 era — I connected it to the WiFi, opened up the browser and realized websites look terrible, a change is needed! It took another 10 years before we got there. Speaking of easy transitions in technology … And guess what? Catchy phrases did not get us there.</p><p>In January 2020 Anna Wiener published <em>Uncanny Valley: A Memoir</em>. She describes how she moved from Brooklyn to San Francisco to work at a mobile-analytics start-up. She witnessed corporate language first hand and names it “garbage language”.</p><p>February 17, 2020 issue of the New York Magazine featured an article entitled “Garbage Language Why do corporations speak the way they do?”, written by Molly Young. She is openly inspired by Wiener, but takes the subject to another level. In the article Young attempts to define garbage language as “words with the scammy flavor”. She states:</p><blockquote><em>As with any scam, the effectiveness lies in the delivery. Thousands of companies have tricked us into believing that a mattress or lip-gloss order is an ideological position.</em></blockquote><p>Wiener and Young focus on empty, made-up neologisms, which are spreading through the corporate world like fire. Examples being: “to parallel-path ”, “to have the bandwidth to do something”, “to operationalize” and so on. Those are not real words, but made-up constructs that get adopted widely and fast. According to Young many times such garbage language fills the space and could be replaced by simpler expressions.</p><p>As much as I agree with Wiener and Young, it seems to me that here is another dimension of garbage language out there. Namely, software engineers, management and others using valid, established language, but with the intent to make them look educated or to give their reasoning more merit than it deserves without regard to the accuracy of expression. For example, naming a simple include a conf.d pattern. It does sound more educated, doesn’t it? It even makes an impression on those who do not have a firm understanding of the subject. Just like garbage language by Young’s definition in this scenario too we are dealing with “scammy flavor” of expressions. People using language like this are trying to scam us. Convincing all around them, that black is white and white is black.</p><h3>Antidote for garbage language</h3><p>Wiener and Young do not offer any suggestions to prevent or to fight garbage language. Why should they? Can we actually do something against the corporate culture? Would a fight just be another Don Quixote attempt at the windmills? Should we just give in?</p><p>Perhaps Young’s definition of a scam resonates the most. When was the last time you allowed a scam artist to scam you? Would you just allow a corporation to steal from you? Why would you then give in when the scam does not necessarily result in an immediate financial loss?</p><p>Admittedly, there is an urge to go with the flow and start using garbage language ourselves in order to fit in and to seemingly benefit from it. Well, each one may decide what would be the best course of action. However, there is something one can do: fight ignorance by educating self and others.</p><p>In the middle ages clergy and aristocracy easily manipulated with the common people. How so? Lack of education. Same is true today, the less we know, the easier targets we are. Do not allow to be “educated” by corporate marketing departments, since they will try to make you believe just about anything. If it would be to them, Tang would be classified as an elixir of life and the key to eternal youth. Of course we know better. Why? Education!</p><p>Go back to the roots therefore, to your alma mater, to established, recognized experts and don’t accept advice from an anonymous user on Stack Exchange or GitHub without a healthy measure of skepticism. Make sure you understand what is being said and verify the statements. Young makes a great point in her article: garbage language is especially effective if expressed with conviction. Therefore, do not skip the process of information verification. If someone sounds as if they know what they are saying, good for them, but you still want to verify the facts. And do not be shy to help others — especially the management — to recognize scam.</p><p>Of course, there is still the other option … blending in: “<em>The novel you just read will improve your fiscal benefits by 20% in the next quarter if you investigate what is the business-critical ask and parallel-path the futureproof initiatives the novel suggests.” ️</em>◼️</p><p>Jon Ackerland</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d66fddeb9bab" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>