-
Notifications
You must be signed in to change notification settings - Fork 467
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
KCL version 1.6.3 doesn't shutdown worker cleanly #79
Comments
I have also experienced shutdown problems with 1.6.3, but I don't think that this is one of them. Does this change to your example program help? (You might also want to apply pull #82 to the library first).
|
Thanks for reporting this. I'm looking into this, and the provided repro should help. |
Thanks! |
How is the investigation going ? |
The shutdown of the worker effectively triggers that instance of the worker to lose all it's leases. Lease loss causes the event loop to call shutdown, instead of process records, on the next iteration. The event loop in worker will only dispatch a single task for a shard at a time. So if a processRecords call is being handled when shutdown is called, nothing will happen until the processRecords call completes. At the same time the lease manager marks the lease as no longer held. So if the record processor calls checkpoint it will receive an exception. This is the body of the race condition, and why your test program shows it reasonably well. The test program calls checkpoint on every processRecords calls. The only way the test program wouldn't cause an exception was if the call to I have some ideas on how to improve shutdown, but I still need to think through them some more. There are some approaches that would allow you to the shutdown behavior you expect. Most of them would require that processRecords determine when it's time to shutdown, and stop processing records. |
Would it make sense to implement a "quiesce" of sorts, so that existing processRecords could complete and perform final checkpointing before the Lease manager destroys itself and erases all records of who owns what ? |
That's pretty much what I'm thinking. There is some difficulty in handling blocked record processors. The other complexity is figuring out how to fit this in while maintaining compatibility with the existing record processors. |
I have a variant of the Kinesis client library that supports quiescing: https://github.com/pfifer/amazon-kinesis-client/tree/determinstic-shutdown I still haven't done any of the unit tests, but have tested the shutdown behavior with my test application. I still need track down, and verify the edge cases especially around handling end of shard scenarios. |
Thanks for the update. I'm still interested in having the solution, when you feel it is mature and well tested. |
I'm hoping to have it complete, and ready for merging later this week. I don't think it will make the 1.7.0 release, but should be ready shortly after that. |
* General * Allow disabling shard synchronization at startup. * Applications can disable shard synchronization at startup. Disabling shard synchronization can application startup times for very large streams. * [PR awslabs#102](awslabs#102) * Applications can now request a graceful shutdown, and record processors that implement the IShutdownNotificationAware will be given a chance to checkpoint before being shutdown. * This adds a [new interface](https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/clientlibrary/interfaces/v2/IShutdownNotificationAware.java), and a [new method on Worker](https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/Worker.java#L539). * [PR awslabs#109](awslabs#109) * Solves [Issue awslabs#79](awslabs#79) * MultiLangDaemon * Applications can now use credential provides that accept string parameters. * [PR awslabs#99](awslabs#99) * Applications can now use different credentials for each service. * [PR awslabs#111](awslabs#111)
* General * Allow disabling shard synchronization at startup. * Applications can disable shard synchronization at startup. Disabling shard synchronization can application startup times for very large streams. * [PR #102](#102) * Applications can now request a graceful shutdown, and record processors that implement the IShutdownNotificationAware will be given a chance to checkpoint before being shutdown. * This adds a [new interface](https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/clientlibrary/interfaces/v2/IShutdownNotificationAware.java), and a [new method on Worker](https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/clientlibrary/lib/worker/Worker.java#L539). * [PR #109](#109) * Solves [Issue #79](#79) * MultiLangDaemon * Applications can now use credential provides that accept string parameters. * [PR #99](#99) * Applications can now use different credentials for each service. * [PR #111](#111)
Graceful shutdown is now merged, and released. It make take a bit for 1.7.1 to become available on Central though. |
still failing in 1.7.2 com.amazonaws.services.kinesis.clientlibrary.exceptions.ShutdownException: Can't update checkpoint - instance doesn't hold the lease for this shard 00:27:00,893 INFO pool-4-thread-1 Worker:shouldShutdown:634 - All record processors have been shutdown successfully. |
To use graceful shutdown you must implement a new interface on your record processor: https://github.com/awslabs/amazon-kinesis-client/blob/master/src/main/java/com/amazonaws/services/kinesis/clientlibrary/interfaces/v2/IShutdownNotificationAware.java You still can't checkpoint in shutdown when the reason is ZOMBIE. |
Hi @pfifer ...i am trying the gracefulshutdown, but it is just waiting for record processors to finish, not sure where it is blocked, processor do not take that much time to complete one batch. shutdown notification, and 9 record processor to complete final shutdown |
…heckpoint - instance doesn't hold the lease for this shard" errors. Spark's KinesisRecordProcessor to implement Kinesis IShutdownNotificationAware interface to be notified before processor will be shutdown so that it can update checkpoint before shutdown. See more details from: - awslabs/amazon-kinesis-client#79 - awslabs/amazon-kinesis-client#109
@akumariiit How did you solve your issue with the graceful shutdown? it doesn't seem to terminate, like ever. |
@akumariiit @stsatlantis We have the same issue. Any update on this? I don't know which process is blocking this shutdown procedure. |
I saw in 1.6.2 release notes that the ability to cleanly shutdown a worker was implemented.
I've put together a reproduction that will demonstrate that this still throws an exception by the worker when attempting to perform the final checkpoint.
See the README for instructions on running the repro scenario:
https://github.com/matthewbogner/kinesis-stress-example
During shutdown of the consumer, you'll see the following exception which shouldn't be occurring:
The text was updated successfully, but these errors were encountered: