Giter Club home page Giter Club logo

Comments (4)

tommyblue avatar tommyblue commented on July 17, 2024

A possible solution is to change the code in https://github.com/vmware/vmware-go-kcl/blob/master/clientlibrary/worker/shard-consumer.go#L256 adding input.Checkpointer.Checkpoint(nil):

if getResp.NextShardIterator == nil {
	log.Infof("Shard %s closed", shard.ID)
	if err := input.Checkpointer.Checkpoint(nil); err != nil {
		return err
	}
	shutdownInput := &kcl.ShutdownInput{ShutdownReason: kcl.TERMINATE, Checkpointer: recordCheckpointer}
	sc.recordProcessor.Shutdown(shutdownInput)
	return nil
}

The problem with this solution is that if ProcessRecords fails somehow, the checkpoint is set to SHARD_END regardless of that failure. I think ProcessRecords would be the right place to set the SHARD_END checkpoint (but it's missing the knowledge to do it) or its return value must be checked (returning an error) before checking whether the shard is closed, because if SHARD_END is put in the checkpointer but ProcessRecords failed, we're probably going to lose data

from vmware-go-kcl.

taoj-action avatar taoj-action commented on July 17, 2024

The library has been tested well for resharding scenario. It does not require restart.
Also, make sure to do checkpointing during shutting down. See example:
https://github.com/vmware/vmware-go-kcl/blob/master/test/worker_test.go#L300

from vmware-go-kcl.

tommyblue avatar tommyblue commented on July 17, 2024

Thanks for the hint on the shutdown, that's exactly what I was looking for! 👍

As per the resharding scenario, we decided to shutdown instances after a resharding not for the resharding itself, but to balance the shards between kcl instances.
Some details: we have long living kcl instances reading from the kinesis streams. Those instances live on AWS EC2 spot servers and, hence, those servers can be killed sometimes due to their spot nature. Without shard stealing we found out that instances with longer lives will read from more shards over time, leading to unbalanced works between servers.
So we decided to use MaxShards based on (n.shards / n. instances) + 1 so that all kcl instances will always read from the ~same number of shards over time.
Since the number of shards changes during a resharding operation, we quit all instances when a resharding happens and then, during the new startup, the correct MaxShards value gets calculated and passed to kcl.

from vmware-go-kcl.

taoj-action avatar taoj-action commented on July 17, 2024

I often found automatic resharding is very annoying and using MaxShards is much easier. See
#4 for more discussion.

Glad to know the issue has been resolved.

from vmware-go-kcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.