Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #848 from prashanthpai/txn-store-metrics
Browse files Browse the repository at this point in the history
txn context: Add store access counters
  • Loading branch information
prashanthpai authored Jun 4, 2018
2 parents cb2cfbe + 3dc494c commit de4188c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 0 additions & 6 deletions glusterd2/commands/volumes/volume-create-txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,6 @@ func newVolinfo(req *api.VolCreateReq) (*volume.Volinfo, error) {

func createVolinfo(c transaction.TxnCtx) error {

// TODO: Reduce the number of txn.Set calls.

var req api.VolCreateReq
if err := c.Get("req", &req); err != nil {
return err
Expand All @@ -187,10 +185,6 @@ func createVolinfo(c transaction.TxnCtx) error {
return err
}

// TODO: Volinfo already has this info. Right now, the key "bricks"
// is set separately to reuse the same step function (validateBricks)
// later in volume expand. Consider duplicating that code if store
// access turns out to be expensive.
if err := c.Set("bricks", volinfo.GetBricks()); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions glusterd2/transaction/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func (c *Tctx) commit() error {
return err
}

expTxn.Add("txn_ctx_store_commit", 1)

c.readCacheDirty = true

return nil
Expand All @@ -133,6 +135,7 @@ func (c *Tctx) Get(key string, value interface{}) error {
c.logger.WithError(err).WithField("key", key).Error("failed to get key from transaction context")
return err
}
expTxn.Add("txn_ctx_store_get", 1)
for _, kv := range resp.Kvs {
c.readSet[string(kv.Key)] = kv.Value
}
Expand Down Expand Up @@ -174,6 +177,7 @@ func (c *Tctx) Delete(key string) error {
"failed to delete key")
return err
}
expTxn.Add("txn_ctx_store_delete", 1)
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions glusterd2/transaction/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (t *Txn) Do() error {
}

if err := s.do(t.Ctx); err != nil {
expTxn.Add("initiated_txn_failure", 1)
if !t.DisableRollback {
t.Ctx.Logger().WithError(err).Error("Transaction failed, rolling back changes")
t.undo(i)
Expand All @@ -142,6 +143,7 @@ func (t *Txn) Do() error {
}
}

expTxn.Add("initiated_txn_success", 1)
return nil
}

Expand Down

0 comments on commit de4188c

Please sign in to comment.