Extra Garlic

21 posts

Extra Garlic banner
Extra Garlic

Extra Garlic

@shawarmaai

BAIT AL SHAWARMA those who know ✊🏼😔

not where I wanna be Katılım Mart 2026
40 Takip Edilen6 Takipçiler
Abdel
Abdel@alemamsha·
spent the last week chasing a distributed concurrency bug. row level locking felt like the right solution but the race just kept happening. turns out i'd been thinking about distributed locks entirely wrong, and the solution was weirder than i expected.
Abdel@alemamsha

I had a strange concurrency bug at work last week, one that made me question my whole understanding of distributed locking. a data race was happening that looked like the standard concurrency issues i'd seen before, two requests were modifying a group of rows at the same time. the standard solution is to find the rows they're both modifying, put a lock on them, and the issue is resolved. this covers a huge class of races, lost updates, dirty writes and other nasty stuff. my bug wasn't like that, the transactions were touching different rows that has share the same "group_id", and i could have tried to lock every row that is being transformed but... that's its own kind of problem, groups in this case can have hundreds or thousands of rows, holding locks on all of them creates contention everywhere and you end up with lock queues that grind throughput to nothing, postgres has a whole class of issues that come from exactly this pattern. what i actually had was something subtler, the rows were connected by a rule i didn't quite see. the book DDIA (chaper 8, v2) used an example that made the problem click for me: We have two doctors on call for the same shift at a hospital, both feel sick at the same time and both open the app to take themselves off call, the app does the responsible thing in each transaction and checks whether at least one other doctor will still be on call before letting them go. both transactions run that check at the same moment, both see that yes the other doctor is still on call, both decide it's safe to proceed, and both commit. the hospital now has zero doctors on call and not a single database rule was broken, no lock would have caught this because each transaction was modifying a different doctor's row. the race wasn't on either doctor's row, it was on this abstract rule that connects them (the invariant) that at least one doctor must remain on call at all times. This is a bit weird to reason about because the rule isn't a row in the database, it's this abstract relationship between rows. this was the gap in my mental model of locking that took me a week to figure out, we get taught to lock rows but sometimes races that exists aren't on rows. the technique described for solving this problem is called materialising conflicts and it sounds obvious once you've seen it. and you would have probably guessed it from reading the above. if the thing you need to lock doesn't exist as a row you create one, a row whose entire job is to be the lock target for that invariant. The hard part is reasoning about the problem and trying to find that invariant. continuing with the example for the doctors you'd create a row representing the on-call shift itself and lock the shift when anyone tries to go off call. the actual on-call data doesn't change but suddenly the race has a concrete row to fail safely on. the pattern to extract is: anywhere two entities share an invariant the race lives in the invariant not in either entity, and if the invariant isn't represented as something you can lock then your locks are pointing at the wrong thing entirely.

English
1
0
0
107
Extra Garlic
Extra Garlic@shawarmaai·
peaked at composite key interval tree
English
0
0
0
19
Extra Garlic
Extra Garlic@shawarmaai·
watch ts go green end of day
Extra Garlic tweet media
English
0
0
1
47
Extra Garlic
Extra Garlic@shawarmaai·
hoping they sign a deal with the union
English
0
0
1
17
Extra Garlic
Extra Garlic@shawarmaai·
what is happening
Extra Garlic tweet media
English
0
0
1
19
Extra Garlic
Extra Garlic@shawarmaai·
Chudded beyond limits of chudness
English
0
0
0
12
Extra Garlic
Extra Garlic@shawarmaai·
+- Couple M14 burgers today
English
0
0
1
19
Extra Garlic
Extra Garlic@shawarmaai·
monday barely started
Extra Garlic tweet media
English
0
0
1
25
Extra Garlic
Extra Garlic@shawarmaai·
@zmcodi u need to be posting these takes on a public acc
English
1
0
0
93
Extra Garlic retweetledi
moneyfetishist
moneyfetishist@moneyfetishist·
I am not going to motivate you because if you need motivation from a stranger on a plane the answer is stay but I will give you the game theory your corporate M&A gig is a repeated game with diminishing marginal returns. year 1 you learn everything. year 2 you refine it. year 3 you are executing pattern recognition. year 4+ you are being paid more to do the same thing with slightly larger numbers. the learning curve flattens but the golden handcuffs tighten because every year the comp goes up and the opportunity cost of leaving gets more painful on paper this is a classic status quo bias trap. the payoff of staying is known and comfortable. the payoff of leaving is uncertain and scary. so you stay not because staying is optimal but because the asymmetry of regret is lopsided. you can imagine regretting the leap. you cannot as easily imagine regretting the years you stayed too long because that regret builds slowly and never hits you in one moment here is where game theory actually helps: in your M&A seat you are playing someone else's game. the firm sets the rules, the deal flow, the comp structure, the promotion timeline. you optimize within their framework. you are a very well-compensated player in a game you did not design. your upside is capped by whatever the partnership or MD economics look like. your downside is protected by a salary. that is the trade owning a local business flips the entire payoff matrix. you design the game. you set the rules. the downside is real and unprotected but the upside is uncapped and compounds in ways a salary never does because you own the equity. a $2M EBITDA business bought at 4x and grown to $3M EBITDA over 3 years is worth $12-15M on exit. no M&A salary trajectory produces that kind of wealth creation in that timeframe unless you are a founding partner the Nash equilibrium of your current situation: you and every other M&A professional are competing for the same promotions, same deal credit, same bonus pool. the competition is fierce because the players are identical. same schools, same skills, same hours. you are in a crowded equilibrium where everyone works 80 hours to stay in the same relative position local business ownership is a different game with different players. the competition is a 62-year-old owner who stopped innovating in 2014 and a 35-year-old who inherited the business and does not want to be there. you walk in with financial sophistication, deal structuring experience, and the ability to read a balance sheet faster than anyone in the room. you are overqualified for the game which is exactly where you want to be. the best strategy in game theory is to play games where your existing skill set gives you an asymmetric advantage over the other players the timing question is about optionality. every year you stay in M&A your financial optionality goes up slightly because you save more. but your operational optionality goes down because you get further from the reality of running anything. the M&A guy who leaves at 28 adapts to operations in 6 months. the one who leaves at 38 has a decade of habits built around delegating to analysts and reviewing decks, and managing a P&L feels foreign in a way it would not have 10 years earlier but again. if you need me to motivate you, stay. the people who actually do this do not need motivation. they need a spreadsheet that shows the math works and then they cannot NOT do it. if you have the spreadsheet and you are still asking strangers for motivation the spreadsheet is not the problem
English
51
207
2.5K
557.2K
Extra Garlic
Extra Garlic@shawarmaai·
what is on my feed get me outta here
English
0
0
0
23
Extra Garlic
Extra Garlic@shawarmaai·
unfresh and unfit
English
0
0
0
20