Author: banyek

  • Dealing with MySQL relay logs when disk space is limited, but the replica is far behind the source

    I just encountered the problem described in the title. On a server I don’t have enough free space to create a backup while the replica is catching up, because the relay logs eat all the available free space as the IO thread works faster than the SQL thread in the replication.

    What to do? First, we need to get rid of the current relay logs, and then limit how many it creates in the future. The relay logs are not meant for manual deletion so we stop the replica, purge the relay logs, set back the replica to the previous position and then restart the mysqld with the relay_log_space_limit variable set up.

    mysql> STOP SLAVE;
    mysql> PAGER egrep "Relay_Master_Log_File|Exec_Master_Log_Pos"
    mysql> SHOW SLAVE STATUS\G
    mysql> RESET SLAVE ALL;
    mysql> CHANGE MASTER TO ...
    mysql> START SLAVE;
    mysql> ^d
    bash> echo "relay-log-space-limit = 10737418240" >>/etc/mysql/my.cnf #10G
    bash> systemctl mysql restart 
    

    As Jean-François Gagné pointed out (rightly), this only applies in a really simple case when there is no GTID configured, no parallel replication exists, the slave is not delayed, no SSL, etc.etc.

  • It seems my problem with one-shot scripts is solved

    I can’t say I am updating my blog too often nowadays, but this seems to be worth an update.

    Github will offer free private repositories for up to three collaborators.

    Here’s the original blogpost about it.

  • What to do with the one-shot scripts

    I can’t really answer this question, but I am really curious.

    During work, I often have small(ish) tasks to solve, and when it is possible I’d rather write small one-shot scripts instead of doing some manual labor.

    These scripts are rough. They are not made perfect because they don’t have to, they have one purpose, and they have to do it right. Sometimes they have small mistakes in them, sometimes they just aren’t perfect, sometimes they are awful. There are always compromises when creating these like ‘is this task worth the extra hours, or should I just aim for a solution to the problem’.

    Let me show this in an example. Today I am working on a script that copies big amounts of data between two servers. I want to do it with multiple threads, but I also want to limit the number of threads.

    My quick and dirty solution looks like this:
    for row in cursor:
    while len(threading.enumerate()) > MAXTHREADS + 1:
    time.sleep(.1)
    worker = Worker(row)

    Yes, I know, civilized people don’t use ‘sleep’, because that is a waste of CPU, but hey, I will run this script on an ephemeral EC2 instance, so I really don’t care. This will do it, so deal with it.

    But after the migration, I do want to keep this script somewhere because it is possible that I’ll need something like this in the future, and I don’t want to reinvent the wheel then.

    My GitHub account would be a perfect place for them, but I am not sure if I can put them there. I mean, a GitHub account is like a business card (remember Patrick Bateman), I don’t want to put ugly code there – I mean if I want to find a new workplace, then it will be possible that they will check my GitHub stuff, and I don’t want them to think I am a bad coder.

    If I had a paid account (which I don’t have) then I’d put these into a private repo.

    Nowadays I put these into gists, but gists are not easy to search, so that is not perfect as well.

    I am not sure what would be the best.

     

  • Going back to my Macbook Air

    I started to work at my current company in 2013. In that year I got a maxed-out MacBook Air, which I loved a lot, but it became a bit storm-beaten. I poured some coffee into it (two or three times) – the first one led to a mainboard replacement, but the others were forgotten, and once my son hammered it a bit – some damage on carousel, and a broken charge connector which was repaired.

    Last year I got a new 15″ maxed-out Macbook pro, and I really didn’t like it, so I was procrastinating the switchover for a few months after the machine was on my desk – I got the machine around May, and I moved to it around October.

    And I bought my old laptop from the company because I liked it.

    I’ve used the new machine for three months so I can articulate my opinion about the new MBP series: they’re a glorious piece of shit. The keyboard is awful – the worst one I had for years, my fingertips hurt a lot – I have to type really hard to get the feedback, and that is painful. The machine is too big for me. It is not convenient to put it on my lap, I have to hold it there, not just put it down. The touch bar is useless, but at least it is easy to accidentally touch it, which will lead to funny moments like reloading a webpage which I use, and the apps I am using aren’t getting any advantage from it. For example, I can change my terminal’s color scheme, or I CAN OPEN A F*CKING MANUAL. That’s just wow. I really needed that, thanks, guys! And as a heavy vim user, I really don’t need a physical escape button for sure.  The force click touchpad is useless as well, but at least I had to learn a new way to interact with finder, and I just don’t want to talk about USB-c.

    So, I decided to move back to my old MacBook Air.

     

     

  • PMM and IAM Roles

    I started to use Percona Monitoring and Management (PMM) recently because it seems promising, and my friends from Percona are always recommending that I try it out, and frankly, at first sight, I like it.

    There are a few things which I am not happy about, but mostly I feel OK – but when it comes to the price/value evaluation it becomes better – it is free.

    However I found a really disturbing problem that is bugging me – it needs AWS credentials to discover hosts on RDS. Let me show you.

    (more…)

  • OSX and case-sensitive file system

    I am really angry now.

    A few weeks ago, when I finished my MySQL backend checker, I lost about two hours of work because I hadn’t committed anything to git, but I overwrote the working file with one of my doodle files – which had the same name but with camel case. I had a default APFS filesystem (on High Sierra) – which is not case sensitive. This was a real amateur mistake, I admit, but the damage was done. I had to recreate everything (actually the second time I was way faster, it took around an hour.)

    (more…)

  • Culture Queries

    When doing interviews in the past, I always had a hard time figuring out how I could ask about those things which are important to me. Let’s face it. When you are in an interview, and you want to know if you are supposed to work on the weekends or not, it is not always the best way to ask about this directly because you’ll have a chance that the company will lie to you about that. So, for example, you can ask instead ‘How responsive are people to emails/Slack over the weekends and after 6pm?’ and then you might have the chance that you’ll have the answer you are looking for.

    I know this because I recently read this on a page at keyvalues. There are a few really good questions there, so I recommend checking the page – you never know when you’ll need this.

     

  • Percona live Dublin – Migrating and living on RDS/Aurora

    It was a long time ago so I won’t write about the conference (it was good as always), but at least I’ll share the slides of my talk here.

    [slideshare id=83493473&doc=migratingandlivingonrdsaurora-171206144942]

  • AWS Profile switching

    The other day, I was sitting in front of my console, and tried to get the courage to run ‘terraform destroy’.

    I started to think about what I should do in the future to avoid situations like this, and then I realized the problem is with the ‘default’ section. When you run the ‘aws configure’ command, it will create a section for you named ‘default’ in the .aws/credentials and .aws/config files. From that very moment you will use that section as your … well, as your default credentials, and when you add more and more keys, you can select them by using ‘–profile’ switch over and over again.

    (more…)

  • I guess I am back again

    This was fun!

    I mean, I did not create any new content here for a while, and I have very good reasons for that – but tbh I was lazy, and overwhelmed with stuff to do.

    We migrated everything to AWS – so be prepared for some Amazon-related posts, I changed MySQL to Aurora and my company itself changed a lot.

    In this pause time, I tried to migrate everything to Jekyll, but it wasn’t a success. Then I spent the time to migrate everything to Hugo … and now I am on WordPress again. Funny.

    In the future, I plan to make the posts here a bit more diverse, not just tech stuff. We’ll see it.