server: Add verification of whether lock was called within out outside of apply

This commit is contained in:
Marek Siarkowicz
2022-04-05 14:32:22 +02:00
parent 6c974a3e31
commit 1d3517020b
5 changed files with 164 additions and 2 deletions

View File

@ -53,6 +53,8 @@ type BatchTx interface {
Commit()
// CommitAndStop commits the previous tx and does not create a new one.
CommitAndStop()
LockInsideApply()
LockOutsideApply()
}
type batchTx struct {
@ -67,6 +69,16 @@ func (t *batchTx) Lock() {
t.Mutex.Lock()
}
func (t *batchTx) LockInsideApply() {
ValidateCalledInsideApply(t.backend.lg)
t.Lock()
}
func (t *batchTx) LockOutsideApply() {
ValidateCalledOutSideApply(t.backend.lg)
t.Lock()
}
func (t *batchTx) Unlock() {
if t.pending >= t.backend.batchLimit {
t.commit(false)