fix(meta): fix some bug for atomic op feature.

1. init buffer pool when fsck run.
2. fix the test case for GetMaskString().
3. check if err == nil before convert status to int.

Signed-off-by: Victor1319 <834863182@qq.com>
This commit is contained in:
Victor1319 2023-07-20 11:47:19 +08:00 committed by leonrayang
parent 9aa539ce50
commit 45c0e18343
4 changed files with 16 additions and 4 deletions

View File

@ -37,6 +37,8 @@ func NewRootCmd() *cobra.Command {
},
}
proto.InitBufferPool(0)
c.AddCommand(
newCheckCmd(),
newCleanCmd(),

View File

@ -759,13 +759,16 @@ func (tm *TransactionManager) delTxFromRM(txId string) (status uint8, err error)
}
resp, err := tm.txProcessor.mp.submit(opFSMTxDelete, val)
status = resp.(uint8)
if err != nil || status != proto.OpOk {
if err != nil {
log.LogWarnf("delTxFromRM: delTxFromRM transaction[%v] failed, err[%v]", txId, err)
return proto.OpTxCommitErr, err
}
log.LogDebugf("delTxFromRM: tx[%v] is deleted successfully", txId)
status = resp.(uint8)
if log.EnableDebug() {
log.LogDebugf("delTxFromRM: tx[%v] is deleted successfully, status (%s)", txId, proto.GetStatusStr(status))
}
return
}

View File

@ -501,6 +501,12 @@ func (p *Packet) GetOpMsg() (m string) {
return
}
func GetStatusStr(status uint8) string {
pkt := &Packet{}
pkt.ResultCode = status
return pkt.GetResultMsg()
}
// GetResultMsg returns the result message.
func (p *Packet) GetResultMsg() (m string) {
if p == nil {

View File

@ -15,7 +15,8 @@ func TestGetMaskFromString(t *testing.T) {
{TxPause, "pause"},
{TxOpMaskAll, "all"},
{TxOpMaskOff, "off"},
{TxOpMaskCreate | TxOpMaskRename, "create|rename"},
{TxOpMaskCreate, "create"},
{TxOpMaskRename, "rename"},
}
for _, c := range cs {