Package txserializer provides the vttablet hot row protection. See the TxSerializer struct for details.
type DoneFunc func()
DoneFunc is returned by Wait() and must be called by the caller.
TxSerializer serializes incoming transactions which target the same row range i.e. table name and WHERE clause are identical. Additional transactions are queued and woken up in arrival order.
This implementation has some parallels to the sync2.Consolidator class. However, there are many substantial differences: - Results are not shared between queued transactions. - Only one waiting transaction and not all are notified when the current one
- Waiting transactions are woken up in FIFO order. - Waiting transactions are unblocked if their context is done. - Both the local queue (per row range) and global queue (whole process) are
limited to avoid that queued transactions can consume the full capacity of vttablet. This is important if the capaciy is finite. For example, the number of RPCs in flight could be limited by the RPC subsystem.
New returns a TxSerializer object.
Pending returns the number of queued transactions (including the ones which are currently in flight.)
ServeHTTP lists the most recent, cached queries and their count.
Wait blocks if another transaction for the same range is already in flight. It returns when this transaction has its turn. "done" is != nil if err == nil and must be called once the transaction is done and the next waiting transaction can be unblocked. "waited" is true if Wait() had to wait for other transactions. "err" is not nil if a) the context is done or b) a queue limit was reached.