#노마드코더 #북클럽 #노개북
전자책으로 참여 신청...!
#노마드코더 #북클럽 #노개북
전자책으로 참여 신청...!
Atomicity
Consistency
Isolation
Durability
common philosophy: Abandon transaction entirely, rather than remain half-finished
leaderless replication : best effort
retry is good, though not perfect
transaction succeed, but network( DB → server ) failed
when failed due to overload → worse
only worth in transient errors
side effects
if client process fails while retrying, any data it was trying to write to the DB is lost
transaction isolation
Rather than blindly relying on tools, we need to develop a good understanding of the kinds of concurrency problems that exist and how to prevent them.
no dirty read : read only committed
no dirty write : overwrite only committed
Repeatable Read
Snapshot Isolation
each transaction reads from a consistent snapshot of database
(see only the old data)
Readers never block writers, writers never block readers
multi-version concurrency control(MVCC)
visibility rules
At the start of the transaction, make a list of proceeding transactions.
client1: read → update
client2: read - > update
client1's update is lost
Prevent by locking
write skew
Transactions update two different objects concurrently and there occurs conflict.
ex. at least 2 doctors should be on_call.
restricted solution
serialization, or explicit lock on rows
phantom
a write in one transaction changes the result of a search query in another tranascation
ex. select → condition → update
between select and update, something changed.
SELECT FOR UPDATE may not help when SELECT returns 0 rows.
materializing conflict : create a table of all possible combinations, and put lock there.
the end result is the same as if they had executed one at a time, serially without any concurrency
read : shared lock
write : exclusive lock
first phase : when the locks are acquired,
second phase : when all the locks are released
predicate lock
index-range locking(next-key locking)
pessimistic concurrency control
optimistic concurrency control
Serializable Snapshot Isolation is promising.
6. Partition (0) | 2021.01.08 |
---|---|
5. Replication (0) | 2021.01.07 |
Document-partitioned index(local index)
Term-partitioned index(global index)
secondary indices are partitioned too. Based on term
one write may require write to multiple partitions
one read only require read from one partition.
fixed number of partitions
dynamic partitioning
Partitioning proportionally to nodes.
due to the overhead and risk of rebalancing, manual commit should join the process
client contact any node → if it does not have right partition, forward.
client contact to routing tier like zookeeper
client be aware of the partitioning
how to make routing decisions?
hard problem.
in case of Zookeeper,
7. Transactions (0) | 2021.01.09 |
---|---|
5. Replication (0) | 2021.01.07 |
synchronous replication
asynchronous replication
setting up new followers
leader failure: failover
HOW-TO
problems
Implementation of replication log
Problems of replication log
Usecases
Handling write conflicts
avoiding conflict
converging toward a consistent state
topology
circular : each write has tag
star
all-to-all : result may be over taken
Leaderless Replicationwith coordinator node / or client write to several nodes
writing to DB when a node is down
quorums for reading and writing
detecting concurrent writes
last write wins
happens-before relationship
version vector : collection of version number from multiple nodes
7. Transactions (0) | 2021.01.09 |
---|---|
6. Partition (0) | 2021.01.08 |