Elixir’s Actor Model
Concurrent computation, it’s unescapable. Elixir is known as a highly available concurrent language, but what does this really mean? Elixir’s concurrency model is built on the Actor Model, but what is it?Continue reading »
For work, I picked up a bug where a CSV export was creating duplicate rows when it shouldn’t have been.
We generate the CSV export with a big ol’ SQL statement in some Elixir workers, and got the bug reproduced and found the problem was with how we did some joins on other columns.
We had something in the statement like this:
LEFT OUTER JOIN `reports` ON `reports`.`id` = `people`.`report_id` LEFT JOIN `addresses` ON `addresses`.`people_id` = `people`.`id` LEFT JOIN `favorite_colors` ON `favorite_colors`.`people_id` = `people.id`
In this highly contrived example, I found out that we’re expecting a single row in the
favorite_colors table for each
person, but we were getting multiple
Every time we had a duplicate row on that joined table, the
LEFT JOIN created two rows in the export, even though there should have been one.
If you’re using any sort of linting in your code (and you should), you will more than likely come across a default rule that screams at you for leaving all those handy
console.logs in your code. Those logs sure give useful information, but it is admittedly an unprofessional (and potentially insecure) thing to leave in your production code. Are there any other options?