RIP Leonard Nimoy

A life is like a garden. Perfect moments can be had, but not preserved, except in memory. Live Long and Prosper

Leonard Nimoy

 

Posted in Thoughts | Tagged

Yup, still searching

We haven't found a house yet, but we are learning many things as we view more properties. Here's some thoughts I had on the topic while searching for a new home.

  • We're getting better and better at narrowing down properties that are worth viewing.
  • As a result, filtering properties is absolutely not an issue after you've started looking. There's only 1 or 2 new properties every day that match our criteria.
  • There's no point for me to improve on Gumbug. I could make it better, but manually looking at 2 properties per day, even if they're mismatched, is not a time sink.
We'll get there. It's just a matter of time.

Posted in Daily Life , UK

Infinite loop of the head full of snot

Maybe I should play Minecraft, but my PC keeps running out of memory. I've been considering buying a second machine for a home server, to host media and other things like Minecraft. So I head out to Amazon and Tom's Hardware to check reviews and prices. Then I decide that I don't really need one just yet. Maybe I should check in with work like I said I would, but my head is full of snot and I wouldn't be able to concentrate on problems, so there's really no point. Maybe I should do something random like going out for a cycle. Yes, going out for a cycle sounds nice, especially because my head is full of snot and I haven't cycled in months, making it an utterly random, irresponsible thing to do. Can't go wrong with that. Except that it's about to rain. Oh well, I guess I'll stay inside then. Maybe I should play Minecraft..

Unsnot yourself faster, head..

Posted in Daily Life , Thoughts | Tagged

That damn bike..

So, it's 2AM and once again I find myself wide awake, but for reasons I did not expect. As the last post made quite clear, lately I've been stressed out quite a lot, and it's easy to lose sight of your long-term goals when you've got so much going on in the short term. All week I was worrying about buying a house, finances, planning holidays, looking for new work and so on. There are so many things that I could improve upon in my life, and I'm actively working on all of those things at the same time. Then I wonder, after I've achieved all those things, what's the one thing I would want to do? And I can only think of one thing that I want to do more than anything else: a no hurries, no schedule, unplanned cycling trip, in Japan, with my girlfriend.

I haven't cycled in months. Even before that I haven't been cycling much for fun since I got a car. I occasionally cycled for exercise, but even that not so much. Still, despite that, I would absolutely love to go back to Japan one more time, take it easy around Atsugi and train up on the flats and the easy hills for a proper long-distance fully loaded touring trip. After every past cycling trip I get new ideas about how to do the next one. There's things about the last trip that I want to improve upon, two in particular: I want to pack lighter, and I want to be more free about my route and my schedule, doing more side activities along the way. That's hard to do when you've got a job (and a mortgage) to get back to, and I don't know if it'll ever happen, but at the very least I can write it down here so I can read it back when I'm 80 and add it to my list of regrets.

It may never happen. It definitely won't happen in the next year. But who knows: if the opportunity presents itself, that's what I want to do.

Things I must do before I die:

  • Become financially independent.
  • Cycling trip
  • Drive the Nordschleife
  • Become immortal
Long ways to go yet! (Smeagol will show the way)

 

Posted in Thoughts

Stress

You know what's not a great way to deal with stress: adding a starred email in your gmail reminding yourself to blog about stress.

This week has been both expectedly and unexpectedly busy. I knew the house hunt would keep me busy, but somehow other things kept happening and I ended up having 4 major things on my mind yesterday and today. And by 'major things' I do mean potentially life-changing things, even if that particular potential isn't very large. The house thing went away today as I officially decided not to make an offer on an apartment that was borderline perfect, but too pricey for what it was. Two other things I won't mention by name here, but one of them had its priority lowered as it's going to be a long-term thing, and the other thing I'm hoping to resolve tomorrow. Bloody hell.

The final thing is, oddly enough, my girlfriend being on holiday. She's out of internet range and I've gotten so used to sending her dumb chat messages throughout the day that I find myself oddly unrelaxed. This usually lasts only a few days, and consciously realizing this today kind of nullified it. Which is nice for now, and she'll be back soon anyway.

It's less than a week since I wrote about happiness and blenders, yet this post and my mindset of the past few days seems miles away from what I wrote back then. Keeping perspective is important but becomes more and more difficult as things pile up. I know I've about reached my limit this week, but I also know that I didn't make any rash decisions and managed to keep things sane. The more often I do this, the better I'll get at it. I hope.

I can't help but think back at the moments of ultimate calm in my past, only attainable on cycling trips without a schedule. Actually, it's even more specific than that: I only ever felt ultimately calm during the one cycling trip, the first Spirit of Japan. It was the only time where I was completely unbound and free, with no schedule or plan for the future, cycling from place to place on the cheap with no immediate risk of money running out and no greater ambition than finding a nice place to put my tent for the night. The incredible purity of that feeling is something I will never experience again in my life. Because I've already experienced it once, and I have a proper life now to get back to that I wouldn't give up for anything. Even if I did, it wouldn't be the same, because it wouldn't be the first free cycling trip; it would be the second. That feeling of utter freedom is one I gladly re-experience in my mind from time to time, remembering how I became the person that I am now. The me of now has no regrets about the past.

Ah, what a great feeling that was. Just writing about it has de-stressed me.

Posted in Thoughts

A tale of two bugs

A long time ago in a content management system far, far away.. a manager was sending out lifecycle emails. These emails would be sent out by the CMS automatically once a day, iterating over all recipients in the system. The CMS would weed out the recipients that did not match the email's filters, those recipents that had opted out, and those that had already received the email. It would then send the email to all the new recipients every night.

Sounds fairly simple, right? Let's complicate things a little: one of the sources of email addresses for these lifecycle emails was a customizable form that would be presented on the public-facing site. Since the email might want to reference some of the fields in the user's form submission, the email module had to be made aware of this data. Because both the email module and the forms module were unaware of each other some glue code had to be introduced: an automated task runs every night and imports form submissions from the forms module and turns them into usable recipients for the email module. For each form submission the task first calculates a checksum over the user's data; if there's already a record in the email module that matches the checksum then the same record won't be copied twice.

This system in the way that it's described here ran for many months without any issues. Until one day, just before I was about to leave of course, a project manager came to me and asked: "How come this email only has 300 form submissions but has been sent 3000 times?". A quick check of the database and server logs didn't show up any obvious bugs, so I knew I'd be working through the evening that day.

The logs confirmed that an email was indeed being sent multiple times to the same recipient. I began by trying to reproduce the problem, and immediately hit frustration. I tried to manually add myself multiple times as a recipient to a new email, but I only received it once. Then I tried to reproduce the entire workflow, creating a form on the public site and trying to register myself via there. Since the form wouldn't allow be to register multiple times, I manually added multiple form submissions for myself with the same email address. That didn't work either. Not only that: the glue code successfully detected that my multiple form submissions had the same checksum, and only created a single email recipient in the email module.

If there's one thing that sucks about programming, it's when things work when you expect them to fail. At least when things fail you've got an obvious thing you can work on, but if things are (seemingly) working you need to figure out how to break them, and that can be way more difficult.

I went back to the logs of the original email to try and find out if there was a pattern to the email addresses that were receiving the email multiple times. Something immediately stood out: out of all the addresses that the email was being sent to, only a single address received the email more than once. The real moment of clarity came when I saw the address: rather than being all lowercase, it looked something like this: "AAaaAA@BBbb.com".

With this clue I managed to reproduce the problem. I first tried to add my own email address to the email module directly using mixed case letters, but this didn't cause me to receive multiple emails. So I repeated the test doing a form submission, ran the glue code task and sent the email again. It worked! Finally I managed to reproducibly break the system.

Now I had two major clues: a) it only happens when the email address is not all-lowercase, and b) it only happens on form submissions. It was pretty easy to debug from there. Here's a step-by-step of what happened.

  • The daily email task starts up and tries to send an email to 'AAA@BBB.COM'
  • It finds that no email was sent yet, so it re-saves the email recipients with the lowercase address 'aaa@bbb.com'. It then sends the email and creates a log record confirming that the email was indeed sent to 'aaa@bbb.com'.
  • The daily data duplication task runs and happily (but mistakenly) adds a new email recipient with the address 'AAA@BBB.COM'.
  • The next day the whole process repeats itself.
Two major bugs!
  1. The email task checked if a sent record existed before sanitizing (lowercasing) the email address.
  2. Because the record in the email module got sanitized, its checksum changed. So the glue task ended up duplicating the same record over and over again every time it ran.
If there was just the data duplication bug then the email address would have gotten sanitized correctly, and only one email would ever have been sent out. If there was just the address sanitizing bug then the recipient would have been sanitized correctly after the first time, and only one email would ever have been sent out. With both bugs present things turned into an infinite loop of sanitizing and duplication.

We deleted the duplicate data, made sure that the checksum check would lowercase all fields when calculating the checksum, and modified the email task to sanitize the email address before doing the 'was-already-sent' check, not after. It would have been better to sanitize all of our existing data and to rewrite the email module, but that never happened. The entire CMS, including the email module, eventually got rewritten from scratch, but that's a story for another time.

Besides the fix, the most important lessons learned were in procedure. Always have an extra set of eyes on critical code. Code reviews are massively useful to catch problems like this. The same goes for unit testing: if we had thought of testing the email address sanitizer, it's quite likely that we would've thought of testing it with mixed case email addresses. Neither code reviews nor unit tests are an absolute guarantee that problems like this won't happen, but they make it a hell of a lot less likely.

Posted in Tech | Tagged

Happiness and Blenders

A lot of people just forget that they're actually happy. Sadly, in the act of forgetting that you are happy, you are making yourself unhappy. If someone asks you "Are you happy?" and you find yourself trying to ascertain if you're happy or not, chances are that you forgot. It's not necessarily a bad thing. It's like leaving the stove on and forgetting about it: best case scenario is that your food is done, worst case scenario is that your house is on fire. Either way, if you don't periodically check, you just don't know.

Some people get really upset when they found out that the set of kitchen knives they just bought went on sale a week later. Or that the blender they bought was not in fact number one best blender of the year 2014. This probably sounds petty to you, but it doesn't have to be petty. I used to think that people who pursue better blenders are the same kind of people who would think that having a house and a mortgage would be the end goal of their life and the absolute thing they would need to be happy. Given that I'm currently looking to purchase a house (and, consequently, a blender) there is definitely some irony at play here. Here's my attempt at nuancing my change of opinion.

When you see people trying to increase their happiness by buying a better blender, what you're really seeing is only the topmost layer of what people think they need to be happy. The fact that they're looking for a blender can either mean that they've already ticked off from their list everything else that could possibly make them more happy than a blender, or it could mean that they're so shallow that they think they only need a blender to be happy. Or something in-between.

I think the foundation of happiness is accepting the phrase "I can be happy with anything". In order to truly accept this, I suspect that you will first have to lose everything. I honestly don't know. I've had my bad times but I've never been particularly close to this statement, which makes my foundation for happiness less-than-optimal. (Although perhaps the realization of this fact offsets the lack of depth a little). People who have this solid foundation for happiness in place will not get upset when they buy a shitty blender: they know that their foundation for happiness lies much deeper.

I know people from both sides of the spectrum. Some get really upset when some trivial thing happens in their life, which may cause them to be unhappy for weeks. Others have the most terrible things happen to them and they laugh it off. Some of my friends are, like me, transitioning from the "I can be happy with anything" mindset into the "Ok, we've established that I can be happy with anything, now where do I get a better blender?"-kind-of-mindset.

Don't forget your foundation, but don't cling too much to it either. Or else you'll never have a nice blender.

 

Posted in Thoughts | Tagged