๐ ๐ผ๐๐ ๐ฒ๐ป๐ด๐ถ๐ป๐ฒ๐ฒ๐ฟ๐ ๐ฟ๐ฒ๐ฎ๐ฐ๐ต ๐ณ๐ผ๐ฟ ๐ฝ๐ฒ๐๐๐ถ๐บ๐ถ๐๐๐ถ๐ฐ ๐น๐ผ๐ฐ๐ธ๐ถ๐ป๐ด ๐ฏ๐ ๐ฑ๐ฒ๐ณ๐ฎ๐๐น๐. ๐๐ผ๐ฟ ๐ฟ๐ฒ๐ฎ๐ฑ-๐ต๐ฒ๐ฎ๐๐ ๐๐๐๐๐ฒ๐บ๐, ๐๐ต๐ฎ๐ ๐ถ๐ ๐๐๐๐ฎ๐น๐น๐ ๐๐ต๐ฒ ๐๐ฟ๐ผ๐ป๐ด ๐ฐ๐ฎ๐น๐น
Alice and Peter both read account #1 at balance 50. Each withdraws 20. Without protection, the second write lands on stale data. One withdrawal vanishes, and the balance shows 30 when it should show 10.
Two strategies stop this, and they make opposite bets.
1. ๐ข๐ฝ๐๐ถ๐บ๐ถ๐๐๐ถ๐ฐ ๐น๐ผ๐ฐ๐ธ๐ถ๐ป๐ด ๐ฏ๐ฒ๐๐ ๐ฐ๐ผ๐ป๐ณ๐น๐ถ๐ฐ๐๐ ๐ฎ๐ฟ๐ฒ ๐ฟ๐ฎ๐ฟ๐ฒ
Nobody takes a lock. Each row carries a version number. Peter writes first, the balance drops to 30, and the version goes from 1 to 2.
When Alice writes with version 1, the database rejects her because the version moved underneath her. She re-reads, gets version 2, and retries.
JPA and Hibernate handle this with the @Version annotation.
2. ๐ฃ๐ฒ๐๐๐ถ๐บ๐ถ๐๐๐ถ๐ฐ ๐น๐ผ๐ฐ๐ธ๐ถ๐ป๐ด ๐ฏ๐ฒ๐๐ ๐ฐ๐ผ๐ป๐ณ๐น๐ถ๐ฐ๐๐ ๐ฎ๐ฟ๐ฒ ๐น๐ถ๐ธ๐ฒ๐น๐
The first writer locks the row. Alice requests account #1 and the database locks it for her. Peter tries to edit and waits, blocked, until she commits.
The lock releases, and Peter reads the fresh balance of 30. In SQL that is SELECT ... FOR UPDATE.
The cost differs. Optimistic locking is cheap when writes rarely collide, but every conflict throws away work and forces a retry. Pessimistic locking guarantees the write, but it holds a lock, so others wait and we risk deadlocks under load.
Pick by contention. Optimistic locking fits read-heavy systems where two people rarely touch the same row, like editing a profile or a product listing. Pessimistic locking fits the cases where collisions are common and a retry costs you, like seat booking or moving money between accounts.
Most lost-update bugs trace back to the wrong bet for the traffic.
Innalilahi wa innailaihi raji'un ๐ฅ
Turut berduka cita atas meninggalnya kiper Palestina, Saleem Al-Ashqar, yang berusia 32 tahun.
Ia meninggal setelah ditembak oleh pasukan Israel pada 30 Juni kemarin di jalur Gaza.
Saleem dilaporkan baru menikah 5 bulan, istrinya hamil anak pertama, dan ia sedang mencoba mendapatkan air saat kejadian tersebut terjadi.
@ilalangdibukit@Ariodillahson Korupsi gak berdosa bang, langsung di bakar di neraka jahanam. Ndak bakal bisa keluar tuh orang jika orang yang terdampak Korupsi nya Ridho dia keluar dari neraka.
@AYB_id Kok bisa ya domba" yang di gembalakan di daerah bebaruan kayak gitu bisa gemuk" , meanwhile kalau kambing / domba di Indonesia kek kurus padahal rumput disini termasuk banyak.
Potongan ceramah Mbah Nun (Emha Ainun Nadjib) di Klaten pada 22 Februari 2012 ini kembali viral dan terasa sangat relevan dengan situasi panas di Timur Tengah saat ini.
Watching these people suffer, especially when it feels relentless and ignored, is heartbreaking on a level thatโs hard to even put into words. Anger. Grief. Disgust. Helplessness.
Free Palestine ๐ต๐ธ
860 hari.
Sendirian.
Setiap hari.
Di tengah keramaian Tokyo.
Orang Jepang ini bernama **Yusuke Furusawa**.
Dia bukan orang Palestina.
Dia bukan aktivis profesional.
Dia cuma orang biasa yang memilih untuk tidak diam.
Setiap hari setelah kerja, dia berdiri dengan plakat โStop Gaza Genocideโ.
Hujan, panas, dihina, diabaikan โ dia tetap datang.
860 hari berturut-turut.
Kita di Indonesia masih banyak yang cuma scroll dan like.
Dia? Dia sudah 860 hari berdiri.
Respek.
Terima kasih, Yusuke.
Kita tidak lupa Gaza. ๐ต๐ธโค๏ธ
#FreePalestine
#GazaGenocide
#YusukeFurusawa
#StandWithPalestine
Today Israel murdered more children.
Hit with US missiles as they slept.
Israel still blocks all journalists from entering Gaza - they cannot allow the world see their barbarity.
Free Palestine
Di Gaza, hampir tiga ribu warga Palestina dilaporkan โlenyapโ tanpa jenazah saat Israel membombardir Palestina sepanjang perang dari 7 Oktober 2023.ย
Investigasi terbaru Al Jazeera menyebut, Israel menggunakan senjata berpanas ekstrem untuk menyerang Gaza dan asal senjata itu dari Amerika.ย
Apa saja temuan investigasi Al Jazeera?
| Narasi Daily