Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

RetMgr: Handle cleanup of consumer-groups and consumer-group extents #310

Merged
merged 22 commits into from
Oct 20, 2017

Conversation

kirg
Copy link
Contributor

@kirg kirg commented Oct 10, 2017

This diff also adds a new API to list consumer-groups for a given destination-uuid -- the difference between this and the existing ListConsumerGroups API is that this one would look at the 'consumer_groups' table (instead of 'consumer_groups_by_name', that ListConsumerGroups look at).

Retention-manager uses this new API to query consumer-groups in 'deleting' state and takes appropriate action to 'delete' them.

@kirg kirg requested review from kobeyang and datoug October 10, 2017 20:11
@@ -1189,9 +1189,26 @@ const (
columnZoneConfigs + `: ?, ` +
columnOptions + `: ? }`

cqlConsumerGroupType = columnConsumerGroup + `.` + columnUUID + "," +
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: sqlConsumerGroupType (to be consistent)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true .. :-)

@@ -60,7 +60,7 @@ func (t *metadataDepImpl) GetDestinations() (destinations []*destinationInfo) {
i := 0
for {

log.Debug("GetDestinations: ListDestinationsByUUID on metadata")
log.Info("GetDestinations: ListDestinationsByUUID on metadata")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these will cause too many logs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure now .. why i decided to enable these. reverting it. :-)

if e != nil {
err = e
log.WithField(common.TagErr, err).Error("GetExtentsForConsumerGroup: ReadConsumerGroupExtentsLite failed")
break
Copy link
Contributor

Choose a reason for hiding this comment

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

return here?

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 do a 'break' so it will print the "done" log below ..

func (t *metadataDepImpl) DeleteConsumerGroup(destID destinationID, cgID consumerGroupID) error {

req := metadata.NewDeleteConsumerGroupUUIDRequest()
req.UUID = common.StringPtr(string(destID))
Copy link
Contributor

Choose a reason for hiding this comment

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

uuid should be cg uuid right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes; fixed.

sqlInsertCGByUUID = `INSERT INTO ` + tableConsumerGroups +
`(` +
columnUUID + `, ` +
columnDestinationUUID + `, ` +
columnIsMultiZone + `, ` +
columnConsumerGroup +
`) VALUES (?, ?,` + sqlCGValue + `)`
Copy link
Contributor

Choose a reason for hiding this comment

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

You need one more '?' here

Copy link
Contributor

Choose a reason for hiding this comment

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

some test should be able to catch this.

@@ -342,10 +435,9 @@ func (t *RetentionManager) runRetention(jobsC chan<- *retentionJob) bool {
totalJobs++
}

if allExtentsDeleted && dest.status == shared.DestinationStatus_DELETING {
if dest.status == shared.DestinationStatus_DELETING && numCGs == 0 && numExtents == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you can rely on 'numCGs == 0' since the error from the below call was swallowed.
cgs := t.metadata.GetConsumerGroups(dest.id)

Copy link
Contributor

Choose a reason for hiding this comment

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

I still don't see this get fixed.

@@ -2003,6 +1987,73 @@ func (s *CassandraMetadataService) ListConsumerGroups(ctx thrift.Context, reques
return result, nil
}

// ListConsumerGroupsUUID returns all ConsumerGroups matching the given destination-uuid.
func (s *CassandraMetadataService) ListConsumerGroupsUUID(ctx thrift.Context, request *shared.ListConsumerGroupsUUIDRequest) (*shared.ListConsumerGroupsUUIDResult_, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add some UT for the new API?

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 have now.

@@ -312,26 +314,117 @@ func (t *RetentionManager) runRetention(jobsC chan<- *retentionJob) bool {
continue
}

log := t.logger.WithField(common.TagDst, dest.id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to UT the new behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it can be .. though it will be quite some work; will give it a shot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as discussed offline, i am going to take this up separately.

@coveralls
Copy link

coveralls commented Oct 17, 2017

Coverage Status

Coverage increased (+0.5%) to 67.431% when pulling 262378c on cg-dest-uuid into 985ade9 on master.

@coveralls
Copy link

coveralls commented Oct 18, 2017

Coverage Status

Coverage increased (+0.2%) to 67.541% when pulling 4c71fb1 on cg-dest-uuid into fc00e42 on master.

inputs = append(inputs, &shared.ListConsumerGroupRequest{
}).Equals(cgSet), "ListConsumerGroups did not return all CGs")

assert.True(listCGs(&shared.ListConsumerGroupRequest{
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this section duplicated from previous one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. removed.

@kirg kirg changed the title Add ListConsumerGroupsUUID metadata API RetMgr: Handle cleanup of consumer-groups and consumer-group extents Oct 20, 2017
@coveralls
Copy link

coveralls commented Oct 20, 2017

Coverage Status

Coverage increased (+0.07%) to 67.571% when pulling 1abe1d8 on cg-dest-uuid into 3ef749a on master.

@kirg kirg merged commit 5652d7a into master Oct 20, 2017
kirg pushed a commit that referenced this pull request Oct 27, 2017
* Revert "Slowdown redeliveries, add timeout metrics (#290)"

This reverts commit 464433e.

* cmq - Cherami Metadata Query-r

* ttt

* show remote extents

* remove binary

* fix rate computation

* flag DLQ extents

* monitor -> watch

* Revert "Slowdown redeliveries, add timeout metrics (#290)" (#316)

This reverts commit 464433e.

* sort by cgx-status updated time

* show milliseconds since update

* mark cgx for consumed extent as consumed

* ~

* ~

* RetMgr: Handle cleanup of consumer-groups and consumer-group extents (#310)

* handle consumer-group deletion

* fix mocks, tests

* debug log

* more log

* log

* metadata logs

* add destination_uuid column to consumer_groups table

* ListConsumerGroupsUUID

* Make RetMgr use ListConsumerGroupsUUID

* update meta-metrics

* thrift

* thrift

* update the new dest-uuid column in create-, update- and delete- cg paths

* fix create-cg cql

* fix mocks

* ListConsumerGroupsUUID test

* CR feedback

* return and catch errors from metadata in ret-mgr

* incorporate cr feedback

* ~

* ensure consumer-groups are deleted before deleting destination

* fix build due to gocql API change

* cmq - Cherami Metadata Query-r

* ttt

* show remote extents

* remove binary

* fix rate computation

* flag DLQ extents

* monitor -> watch

* sort by cgx-status updated time

* show milliseconds since update

* mark cgx for consumed extent as consumed

* ~

* ~

* ...

* cg deleting

* fix build

* yaml config support

* cmq zone

* output type support

* json map output

* fix lint

* fix lint

* fix build

* fix lint
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants