๐ Available for Freelance / Contract Work
I help startups & businesses:
โ UI Design (Canvas)
โ React web apps
โ Java Spring Boot APIs
โ Payments & integrations
โ Deployment
Design + Code in one place โก
Fast delivery โข Reliable
DMs open ๐ค RT appreciated ๐
@sirHaleus@AF_Deplorables@FishbackStAug Well Thereโs signs, but Iโm not sureโฆ Have you noticed your interactions dropping lately? Also Your views donโt match your follower count, itโs kind of obvious somethingโs off, but if youโd like to check and see for sure or even clear it just say & Iโll give you the steps.
Take a second, actually trace through the code in your head before you scroll past this.
func(1) then func(2) โ same list both times, or fresh list each time? ๐ค
That's the whole question. Simple to read, easy to get wrong.
Comment your answer below (A/B/C/D) โ
The whole team came to @defcon this year, spouses included. Theyโre not technical but they are diving right into everything at the con, including picking their tags.
If you see them, teach them something cool ๐
MVCC โ Locking โ Optimistic Concurrency
When multiple transactions access the same database row at the same time, you need a strategy to prevent lost updates, inconsistent reads, and race conditions.
These three approaches solve concurrency differently.
Quick memory trick
MVCC = Keep multiple versions
Locking = Make others wait
Optimistic Concurrency = Detect conflicts and retry
-------------------------------------------
MVCC - Multi-Version Concurrency Control
Instead of making readers wait for writers...
The database maintains multiple versions of a row.
Transaction T1 โ Read Version 1
Transaction T2 โ Update
โ Creates Version 2
T1 โ Can still read its consistent snapshot
Readers don't necessarily block writers.
That's why MVCC works extremely well for read-heavy workloads.
Commonly associated with databases such as:
- PostgreSQL
- MySQL/InnoDB
- Oracle
๐ Think: Readers see a snapshot.
---------------------------------------------
Locking
With locking, transactions explicitly control access to data.
T1 โ Acquire Lock
โ Update Row
โ Commit
โ Release Lock
T2 โ WAIT...
Other transactions may have to wait until the lock is released.
Common examples:
SELECT *
FROM orders
WHERE id = 101
FOR UPDATE;
Useful when you need strong control over concurrent modifications.
But excessive locking can cause:
โBlocking
โLock contention
โDeadlocks
๐ Think: One transaction holds the door.
----------------------------------------------
Optimistic Concurrency
Instead of locking the row...
Assume conflicts are relatively rare.
Read the row with a version:
Order ID = 101
Version = 5
Update only if the version hasn't changed:
UPDATE orders
SET status = 'PAID',
version = 6
WHERE id = 101
AND version = 5;
If 0 rows are updated...
Someone changed the record first.
The application detects the conflict and can:
- Reload
- Recalculate
- Retry
๐ Think: Don't block- detect conflicts later.
-----------------------------------------------
The real-world scenario
Two users edit the same account.
Balance = โน10,000
Version = 5
Both read version 5.
MVCC
Each transaction works with its appropriate database snapshot/version according to the database's isolation semantics.
Locking
User A โ Lock row
User B โ WAIT
Optimistic Concurrency
User A โ Version 5 โ Update โ Version 6โ
User B โ Version 5 โ Update โ 0 rowsโ
โ
Conflict detected
This is where optimistic concurrency shines.
------------------------------------------------
When should you use each?
MVCC
Best when:
- Reads are frequent
- High concurrency is expected
- Readers shouldn't unnecessarily block writers
- Your database supports MVCC
๐ Great default for modern OLTP databases.
------------------------------------------------
Locking
Best when:
- Conflicts are frequent
- Critical resources must be serialized
- You need explicit control over concurrent updates
- Waiting is preferable to retrying
๐ Use when coordination matters more than concurrency.
---------------------------------------------
Optimistic Concurrency
Best when:
- Conflicts are relatively rare
- You want minimal blocking
- Applications can retry
- Updates are version-controlled
๐ Great for APIs and user-driven updates.
-----------------------------------------------
Biggest misconception
MVCC and Optimistic Concurrency are the same.
They are not.
MVCC is primarily a database concurrency-control technique using multiple row versions/snapshots.
Optimistic concurrency is a broader strategy where conflicts are detected rather than preventing them upfront.
You can actually use optimistic locking on top of a database that uses MVCC.
------------------------------------------------
Another misconception
Locking is always slower.
Not necessarily.
If conflicts are frequent, repeatedly failing and retrying optimistic updates can be more expensive than simply waiting for a lock.
The right choice depends on:
- Conflict frequency
- Read/write ratio
- Transaction duration
- Retry cost
- Consistency requirements
-----------------------------------------
One sentence to remember forever
MVCC โ Multiple versions
Locking โ Block conflicting access
Optimistic Concurrency โ Detect conflict and retry
The important part isn't memorizing the terminology.
It's understanding what happens when two transactions try to modify the same data at the same time.
That's where database concurrency becomes a real production problem.
These Cayley graphs visualize groups:
- Cโ cycles three elements,
- Sโ captures all triangle symmetries,
- CโรCโ combines two cycles, and
- Cโยณ forms the cubeโs edge network.
They power secure encryption, quantum circuits, and AI that respects rotational symmetry.
After spending 4 years on YouTube and 2.5 years on X, here's one observation:
YouTube
> Content takes significantly more effort to create.
> But its monetization ecosystem has been consistent, predictable, and easier to plan around.
X
> It has opened multiple ways for creators to monetize beyond just one program.
> At the same time, the monetization landscape continues to evolve, so adapting has become part of the journey.
Every platform rewards creators differently.
The key isn't chasing the "best" platform - it's understanding how each platform works and building a strategy around its strengths.