Alex Petrov commented on CASSANDRA-12461:

I've discovered several more problems while working on this patch:

  * node drain code was duplicated (with minor differences, which I indicate 
  * if the node was drained, under Windows the timer resolution (added in 
[CASSANDRA-9634]) was not reset, since the node was considered "already 
  * same was happening with post-shutdown hooks, since 
 we'll return from runnable, since those services were shut down during 

This is one of the reasons I was advocating for a single consistent drain 
I also suggest disallowing re-enabling auto-compaction, binary, gossip, handoff 
and thrift to ensure that we do not need to re-stop them in the final shutdown 
hook. Operator can not bring the node into "working" state after drain without 
restart anyways (one of the reasons is the fact that commit log is shut down by 
that time), and it was most likely never intended to do so. However, it might 
be useful for operator to run compactions on the drained node, so we only shut 
down compaction manager later. 

I've made a comparison table to make it easier to see what {{drain()}} method 
was doing compared to {{drainOnShutdown}} runnable:

|| nodetool drain || shutdown drain hook |
| disables autocompaction               |                                       
| shuts down compaction manager | |
| recycles commitlog segment recycling |                                        
| shuts down batchlog and hints earlier |                                       
|                                       | flushes only tables with 
durable_writes |
|                                       | clears set timer resolution for 
windows |

I've combined the two processes, made clearer distinctions to allow running 
things in {{drainOnShutdown}}. Since we can run all the items from the 
{{nodetool drain}} part of the list during the normal node shutdown, the code 
got a bit simpler, too (the only difference is now logging). 

Preliminary version of the update (also, CI pending): 

(I've discussed the change "in theory" with [~slebresne], although it's still 
worth for someone to take a deeper look at it, I'll ask around)

> Add hooks to StorageService shutdown
> ------------------------------------
>                 Key: CASSANDRA-12461
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12461
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Anthony Cozzie
>            Assignee: Anthony Cozzie
>             Fix For: 3.x
>         Attachments: 
> 0001-CASSANDRA-12461-add-C-support-for-shutdown-runnables.patch
> The JVM will usually run shutdown hooks in parallel.  This can lead to 
> synchronization problems between Cassandra, services that depend on it, and 
> services it depends on.  This patch adds some simple support for shutdown 
> hooks to StorageService.
> This should nearly solve CASSANDRA-12011

This message was sent by Atlassian JIRA

Reply via email to