java
7 minConcurrentHashMap Internals: Coordinating Updates Without One Global Lock
Understand how modern ConcurrentHashMap combines volatile reads, CAS, and narrow bin-level locking, and where its guarantees stop.
Loading page...
java
7 minUnderstand how modern ConcurrentHashMap combines volatile reads, CAS, and narrow bin-level locking, and where its guarantees stop.
databases
19 minReason about isolation anomalies, query-plan mistakes, B-tree/LSM trade-offs, shard routing, and production-safe index changes.
Q&A
Q&AHashMap stores entries in buckets, resolves collisions with linked lists or trees, and resizes when load crosses a threshold.
HashMap uses an array of buckets and computes an index from the hash of the key. Each bucket may hold one or more entries. When collisions happen, Java stores entries in a linked list and later in a tree when the bucket grows large enough. The table resizes when the load factor is exceeded so the map keeps operations efficient. The key idea is balancing fast lookup with controlled memory use.
Q&A
Q&AConcurrentHashMap is designed for concurrent reads and writes without locking the entire map.
Modern Java ConcurrentHashMap does not use the fixed lock segments from older implementations. It uses non-blocking reads and coordinates updates with CAS and synchronization at individual bins when needed. This allows unrelated keys to make progress concurrently. It protects map operations, not a multi-key transaction or mutable values stored inside it.
Q&A
Q&AKeep consumer liveness within max.poll.interval.ms and commit only after durable work.
If processing exceeds max.poll.interval.ms, the group may consider the member failed and reassign its partitions; a later commit from the old generation is rejected. Reduce records per poll, process with bounded workers while preserving partition ordering, pause/resume appropriately, or adjust the interval based on measured worst-case work. Keep the fix from merely delaying failure detection indefinitely.
databases
5 minInvestigate missing heartbeats with PostgreSQL interval arithmetic and a separate SQLite integer-millisecond contract.
kubernetes
5 minConnect replaceable Pods through stable Services and reason about configuration, credentials, namespaces, and workload API permissions.