-
Notifications
You must be signed in to change notification settings - Fork 82
Conversation
4e2895e
to
0a4df19
Compare
55bb33c
to
89a0b73
Compare
@oshankkumar Can we please have 'Fixes' or 'Updates' tag in the commit message? |
@oshankkumar It might be worth to mention which all parts of #919 are covered here and what's pending. This will give us a good heads up for the reviewers. |
847ff5f
to
c537254
Compare
Task List
|
8fe9508
to
1733ca1
Compare
210a04f
to
1055b69
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great. Looks good overall from the logic and structuring. I have several general comments about style. In addition, please try to add more comment through the code. Especially for the unexported helper functions, this will make understanding the code much easier in the future.
@@ -33,29 +33,32 @@ type TxnCtx interface { | |||
// Logger returns the Logrus logger associated with the context | |||
Logger() log.FieldLogger | |||
|
|||
// commit writes all locally cached keys and values into the store using | |||
// Commit writes all locally cached keys and values into the store using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear here. You're exporting this and the other types and functions in this package, because of the new package, right? Once we refactor out the old package, these can go back to being unexported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Kaushal, I have made few things exported because I wanted to use in new package
|
||
const ( | ||
leaderKey = "leader" | ||
cleanupTimerDur = time.Second * 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep the timer durations for longer. I'm looking at this in minutes rather than seconds.
|
||
// StartElecting triggers a new election after every `electionTimerDur`. | ||
// If it succeeded then it assumes the leader role and returns | ||
func (c *CleanupHandler) StartElecting() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For leader election, I'd prefer if we use github.com/coreos/etcd/clientv3/concurrency.Election
, instead of rolling our own.
The concurrency package is already used elsewhere in the store package for concurrency.Session
.
glusterd2/transactionv2/engine.go
Outdated
|
||
// TxnEngine executes the given transaction across the cluster. | ||
// It makes use of etcd as the means of communication between nodes. | ||
type TxnEngine struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment on the naming. You can have this be just Engine
. The rest of the names with txn
prefix can also do without it. For things like the StepManager
you can have the prefix.
glusterd2/transactionv2/engine.go
Outdated
) | ||
|
||
// TransactionEngine is responsible for executing newly added txn | ||
var TransactionEngine *TxnEngine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you plan to use this variable outside this package? I don't think you really need to export this.
glusterd2/transactionv2/engine.go
Outdated
} | ||
|
||
if err := txnEng.stepManager.RunStep(ctx, step, txn.Ctx); err != nil { | ||
txn.Ctx.Logger().WithError(err).Errorf("failed in executing step %+v", step) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using log.*f
variants of the log functions. Instead add context to the log message using WithField
or WithFields
.
glusterd2/transactionv2/engine.go
Outdated
txn.Ctx.Logger().WithError(err).Errorf("encounter an error in synchronizing txn step %+v", step) | ||
return err | ||
} | ||
txn.Ctx.Logger().Info("transaction got synchronized") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a debug log. Other than transaction started and finished logs, everything else should be debug. If needed any error logs should contain the full context to help identify the error cause.
a866695
to
526cb04
Compare
retest this please |
@nigelbabu we have a CI failure, any hint why its failing?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I'll approve once I test this out.
526cb04
to
5181ab5
Compare
5181ab5
to
01a6f06
Compare
@kshlm Did you get a chance to test this? Can we please expedite to get this PR in? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay in my response here. I tested this out, and it mostly works. Still though, the existing transactions need to be updated to sync the required steps. This mostly is having the 'store' steps be synchronized. There are also a few other steps that would require synchronization, like the barrier activate step in snapshot. Please complete this before we can move on to merging.
return ErrLockExists | ||
} | ||
|
||
logger := t.Ctx.Logger().WithField("lockID", lockID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore the logs here. They can be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restored the previous logs
0840cfa
to
cc26978
Compare
The transaction engine executes the given transaction across the cluster.The engine is designed to make use of etcd as the means of communication between peers. Please refer Design Document gluster#1003 cleanup leader: added a cleanup leader which will perform all cleaning operation. A leader is elected among the peers in the cluster to cleanup stale transactions. The leader periodically scans the pending transaction namespace for failed and stale transactions, and cleans them up if rollback is completed by all peers involved in the transaction. Signed-off-by: Oshank Kumar <okumar@redhat.com>
Signed-off-by: Oshank Kumar <okumar@redhat.com>
Signed-off-by: Oshank Kumar <okumar@redhat.com>
Signed-off-by: Oshank Kumar <okumar@redhat.com>
The transaction engine executes the given transaction
across the cluster.The engine is designed to make use
of etcd as the means of communication between peers.
Please refer Design Document #1003
Signed-off-by: Oshank Kumar okumar@redhat.com