Tag

optimistic lock

0 views collected around this technical thread.

Lobster Programming
Lobster Programming
May 30, 2025 · Backend Development

How to Ensure API Idempotency with Locks: 5 Proven Strategies

This article explores five practical lock-based approaches—including database primary keys, pessimistic and optimistic locks, state machines, and distributed locks—to achieve reliable API idempotency in distributed systems, highlighting implementation details, trade‑offs, and code examples.

API idempotencyDistributed Lockdatabase lock
0 likes · 7 min read
How to Ensure API Idempotency with Locks: 5 Proven Strategies
Java Tech Enthusiast
Java Tech Enthusiast
Apr 19, 2025 · Backend Development

Preventing Product Overselling in High‑Concurrency E‑Commerce Systems

To prevent overselling during flash sales, the article explains how non‑atomic database updates cause negative stock and presents solutions such as optimistic DB locking, Redis Lua atomic deductions, Redisson distributed locks, transactional message queues, and pre‑deduction with rate limiting, recommending a combined approach that achieved 120 000 QPS with zero oversell.

Distributed LockMessage QueueRedis
0 likes · 7 min read
Preventing Product Overselling in High‑Concurrency E‑Commerce Systems
Cognitive Technology Team
Cognitive Technology Team
Apr 11, 2025 · Databases

Understanding MySQL Concurrency: Read/Write Conflicts, MVCC, and Locking Strategies

This article explains MySQL's three concurrency types—read‑read, read‑write, and write‑write—describes how InnoDB uses MVCC, shared and exclusive locks, and provides practical examples and code for handling update‑loss and write‑write conflicts with optimistic and pessimistic locking.

DatabaseMVCCMySQL
0 likes · 8 min read
Understanding MySQL Concurrency: Read/Write Conflicts, MVCC, and Locking Strategies
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Apr 1, 2025 · Databases

Understanding MySQL Optimistic Lock: Principles and Implementation

This article explains the concept of MySQL optimistic locking, its underlying version‑or‑timestamp mechanism, and provides step‑by‑step SQL examples for adding a version column, reading data, and safely updating records while handling concurrent modifications.

DatabaseMySQLVersioning
0 likes · 4 min read
Understanding MySQL Optimistic Lock: Principles and Implementation
Bilibili Tech
Bilibili Tech
Sep 27, 2024 · Backend Development

Concurrency Issues and Race Condition Mitigation in Bilibili's Content Production System

Bilibili tackled race‑condition vulnerabilities in its massive video content pipeline by replacing simple timestamp checks with optimistic locking (CAS) and rate‑limiting locks, adding version verification and observation tools that now eliminate missed reviews and improve security, scalability, and real‑time editing reliability.

Backend DevelopmentBilibiliRace Condition
0 likes · 10 min read
Concurrency Issues and Race Condition Mitigation in Bilibili's Content Production System
Lobster Programming
Lobster Programming
May 18, 2024 · Backend Development

How to Prevent Inventory Overselling in High‑Traffic E‑Commerce Systems

This article explains several common technical solutions—locking queues, update‑statement limits, optimistic locking, temporary tables, and Redis pre‑stocking—to prevent inventory overselling, comparing their suitability for different concurrency levels and recommending the best approach for high‑traffic scenarios.

InventoryRedisconcurrency
0 likes · 5 min read
How to Prevent Inventory Overselling in High‑Traffic E‑Commerce Systems
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Apr 17, 2024 · Backend Development

Understanding Idempotence and Common Backend Solutions

The article explains the concept of idempotence in computing, illustrates typical duplicate‑request scenarios, and presents three practical backend solutions—unique database indexes, optimistic locking with version control, and a Redis‑based token mechanism—along with their advantages, trade‑offs, and implementation details.

BackendDatabaseHTTP
0 likes · 7 min read
Understanding Idempotence and Common Backend Solutions
Java Tech Enthusiast
Java Tech Enthusiast
Apr 6, 2024 · Backend Development

Inventory Deduction and Concurrency Control in Backend Systems

The article outlines the three‑step inventory deduction workflow—select, verify, update—and explains how concurrent requests can cause overselling, then compares mitigation strategies such as pessimistic SELECT FOR UPDATE locks, optimistic CAS version retries, atomic decrement SQL statements, and Redis transactions, highlighting their trade‑offs in consistency and throughput.

InventoryRedisconcurrency
0 likes · 5 min read
Inventory Deduction and Concurrency Control in Backend Systems
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Feb 14, 2024 · Backend Development

Mastering Redis Optimistic Lock in Spring Boot: A Hands‑On Guide

This tutorial explains how Redis optimistic locking works, demonstrates the WATCH, MULTI, EXEC, and DISCARD commands with live examples, and shows how to integrate the mechanism into a Spring Boot application using retry logic to handle concurrent updates safely.

JavaRedisSpring Boot
0 likes · 7 min read
Mastering Redis Optimistic Lock in Spring Boot: A Hands‑On Guide
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Jan 19, 2024 · Backend Development

Optimistic Lock: Four Implementation Methods, Principles, and Use Cases

This article explains the concept of optimistic locking in concurrent programming, details four common implementation approaches—version number, timestamp, CAS, and serial number—their underlying mechanisms, and outlines typical scenarios where optimistic locks improve data consistency and performance.

CASDatabaseVersioning
0 likes · 6 min read
Optimistic Lock: Four Implementation Methods, Principles, and Use Cases
Selected Java Interview Questions
Selected Java Interview Questions
Jan 15, 2024 · Backend Development

Preventing Inventory Overselling in High‑Concurrency Scenarios: Java, Redis Distributed Lock, MySQL Row Lock, Optimistic Lock, and SQL Solutions

The article analyzes the inventory oversell problem caused by concurrent purchase requests and presents four backend solutions—including a Redis distributed lock, MySQL row lock, optimistic locking with version fields, and conditional SQL updates—illustrated with Java code and SQL examples to ensure data consistency.

Distributed LockJavaMySQL
0 likes · 10 min read
Preventing Inventory Overselling in High‑Concurrency Scenarios: Java, Redis Distributed Lock, MySQL Row Lock, Optimistic Lock, and SQL Solutions
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Nov 19, 2023 · Backend Development

Mastering Pessimistic and Optimistic Locks in Spring Boot 2.6.12

This article explains the concepts of pessimistic and optimistic locking, compares their use cases, demonstrates version‑based and CAS implementations, and shows a complete Spring Boot example with retry‑enabled optimistic lock handling using AOP and custom annotations.

JPAJava ConcurrencySpring Boot
0 likes · 12 min read
Mastering Pessimistic and Optimistic Locks in Spring Boot 2.6.12
Architect
Architect
Jul 4, 2023 · Databases

Designing Concurrency‑Safe Balance Updates: SQL, CAS, Optimistic Lock, and Distributed Locks

The article examines multiple techniques—including direct SQL updates, compare‑and‑swap, optimistic locking, Redis‑based distributed locks, and MySQL shared locks—to ensure correct and consistent account balance modifications and order status changes in high‑concurrency scenarios.

Distributed LockSQLconcurrency
0 likes · 7 min read
Designing Concurrency‑Safe Balance Updates: SQL, CAS, Optimistic Lock, and Distributed Locks
政采云技术
政采云技术
Mar 23, 2023 · Backend Development

Distributed Locks: Concepts, Characteristics, and Common Implementation Strategies

This article explains the need for distributed locks in multi‑node systems, describes their core characteristics, and compares popular implementation approaches such as database‑based optimistic and pessimistic locks, Redis atomic locks, and ZooKeeper sequential node locks, highlighting their principles and trade‑offs.

Distributed LockRedisZookeeper
0 likes · 8 min read
Distributed Locks: Concepts, Characteristics, and Common Implementation Strategies
Selected Java Interview Questions
Selected Java Interview Questions
Feb 23, 2023 · Backend Development

Understanding Lock Strategies: Optimistic, Pessimistic, Read‑Write, Heavy/Light, Fairness and Reentrancy

This article explains various lock strategies—including optimistic and pessimistic locks, read‑write locks, heavyweight vs. lightweight locks, spin locks, fair vs. unfair locks, and reentrant locks—detailing their definitions, use‑cases, underlying mechanisms, and illustrative examples for concurrent programming in Java and other languages.

Javaconcurrencylocking
0 likes · 10 min read
Understanding Lock Strategies: Optimistic, Pessimistic, Read‑Write, Heavy/Light, Fairness and Reentrancy
Mike Chen's Internet Architecture
Mike Chen's Internet Architecture
Jun 26, 2022 · Backend Development

Ensuring API Idempotency: Concepts, Importance, and Practical Solutions

This article explains the concept of idempotency in distributed systems, why it is crucial for scenarios like payments and order submission, and presents practical solutions such as database unique keys, optimistic locking, the Post/Redirect/Get pattern, and anti‑repeat token mechanisms, complete with code examples.

APIDatabaseIdempotency
0 likes · 7 min read
Ensuring API Idempotency: Concepts, Importance, and Practical Solutions
IT Services Circle
IT Services Circle
Jun 25, 2022 · Databases

Understanding Optimistic and Pessimistic Locks in MySQL

Optimistic and pessimistic locks are conceptual concurrency control strategies used across databases and caching systems; the article explains their principles, MySQL implementations with SELECT ... FOR UPDATE and version checks, compares their trade‑offs, and advises preferring optimistic locking in high‑concurrency scenarios.

DatabaseMySQLconcurrency control
0 likes · 6 min read
Understanding Optimistic and Pessimistic Locks in MySQL