Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish replication task to Kafka after reading from replicator queue #632

Merged
merged 2 commits into from
Mar 26, 2018

Conversation

samarabbas
Copy link
Contributor

Created QueueProcessorBase which has common logic used by both transfer
queue procesor and replication queue processor.

Created replicationQueueProcessor which processes replication task from
replicator queue and publishes it to Kafka.

Bootstrap logic for replicationQueueProcessor to host it within
historyEngine. Also bootstrap logic to pass in kafka publisher to
history engine.

History engine changes to update replication state on
StartWorkflowExecution and UpdateWorkflowExecution by updating the
failover version from domain and writing it to mutable state.

@coveralls
Copy link

coveralls commented Mar 26, 2018

Coverage Status

Coverage decreased (-0.2%) to 63.518% when pulling 56752cc on samarabbas:replicator-queue into 115a38a on uber:master.

func (e *mutableStateBuilder) ApplyReplicationStateUpdates(failoverVersion int64) {
e.replicationState.CurrentVersion = failoverVersion
e.replicationState.LastWriteVersion = failoverVersion
e.replicationState.LastWriteEventID = e.hBuilder.nextEventID - 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make this attr NextEventID? so no need to do the -1 operation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll put a TODO comment for this now. Replication protocol currently uses LastWriteEventID so I don't want to mess with the terminology. But I see your point. I'll rename this when I start work on the replication protocol part of changes.

func (p *queueProcessorBase) processWithRetry(task queueTaskInfo) {
p.logger.Debugf("Processing task: %v, type: %v", task.GetTaskID(), task.GetTaskType())
ProcessRetryLoop:
for retryCount := 1; retryCount <= 100; retryCount++ {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retryCount should be configurable, ie. a const / var or input parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Let me make this change.

a.Lock()
MoveAckLevelLoop:
for current := a.ackLevel + 1; current <= a.readLevel; current++ {
if acked, ok := a.outstandingTasks[current]; ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably panic if !ok, i.e. key not found.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well for now I ported over the existing logic. Let me add a comment address what happens if !ok.

// It keeps track of read level when dispatching tasks to processor and maintains a map of outstanding tasks.
// Outstanding tasks map uses the task id sequencer as the key, which is used by updateAckLevel to move the ack level
// for the shard when all preceding tasks are acknowledged.
ackManager struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we separate this ack manager into a dedicated file? that will be easier to add unit test and have separation of logic which will make the code more readable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now it is not used by any other component and only implementation detail of queue processor. Let me put a comment to move this outside.

Copy link
Contributor

@wxing1292 wxing1292 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit test please.

Created QueueProcessorBase which has common logic used by both transfer
queue procesor and replication queue processor.

Created replicationQueueProcessor which processes replication task from
replicator queue and publishes it to Kafka.

Bootstrap logic for replicationQueueProcessor to host it within
historyEngine.  Also bootstrap logic to pass in kafka publisher to
history engine.

History engine changes to update replication state on
StartWorkflowExecution and UpdateWorkflowExecution by updating the
failover version from domain and writing it to mutable state.
@samarabbas samarabbas merged commit 314d222 into cadence-workflow:master Mar 26, 2018
@samarabbas samarabbas deleted the replicator-queue branch March 26, 2018 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants