Implementing the Cancel Callback Function
Your User-Defined Transform Function (UDTF) or Analytic Function (UDAnF) can implement a cancel()
callback function that Vertica calls if the query that called the function has been canceled. You usually implement this function to perform an orderly shutdown of any additional processing that your UDx spawned. For example, you can have your cancel()
function shut down threads that your UDx has spawned or signal a third-party library that it needs to stop processing and exit. Your cancel()
function should leave your UDx's function class ready to be destroyed, since Vertica calls the UDx's destroy function after the cancel function has exited.
Notes
- If your UDTF or UDAnF does not implement
cancel()
, Vertica assumes your UDx does not need to perform any special cancel processing, and calls the function class'sdestroy()
function to have it free any resources (see Resource Use for C++ UDxs). - Your
cancel()
function is called from a different thread than the thread running your UDx'sprocessPartition()
function. - The call to the
cancel()
function is not synchronized in any way with your UDx'sprocessPartition()
function. If you need yourprocessPartition()
function to exit before yourcancel()
function performs some action (killing threads, for example) you need to have the two function synchronize their actions. - If your
cancel()
function runs for too long, Vertica kills the side process running your function, if it is running in Fenced Mode.