From 94f0c8f0df29f39efb1a2048e3cf3119d578c8dd Mon Sep 17 00:00:00 2001 From: ekexium Date: Sun, 7 Apr 2024 21:11:45 +0800 Subject: [PATCH] comment: explain usage Signed-off-by: ekexium --- txnkv/transaction/txn.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/txnkv/transaction/txn.go b/txnkv/transaction/txn.go index 68bf73f33..2546e35e2 100644 --- a/txnkv/transaction/txn.go +++ b/txnkv/transaction/txn.go @@ -397,8 +397,14 @@ func (txn *KVTxn) SetTxnSource(txnSource uint64) { // SetSessionID sets the session ID of the transaction. // If the committer is not initialized yet, the function won't take effect. +// It is supposed to be set before performing any writes in the transaction to avoid data race. +// It is designed to be called in ActivateTxn(), though subject to change. // It is especially useful for pipelined transactions, as its committer is initialized immediately // when the transaction is created. +// +// Note that commiter may also obtain a sessionID from context directly via sessionIDCtxKey. +// TODO: consider unifying them. + func (txn *KVTxn) SetSessionID(sessionID uint64) { if txn.committer != nil { txn.committer.sessionID = sessionID