Garbage Collection in teradataml - Teradata Python Package

Teradata® Python Package User Guide

Product
Teradata Python Package
Release Number
16.20
Published
February 2020
Language
English (United States)
Last Update
2020-02-29
dita:mapPath
rkb1531260709148.ditamap
dita:ditavalPath
Generic_no_ie_no_tempfilter.ditaval
dita:id
B700-4006
lifecycle
previous
Product Category
Teradata Vantage

teradataml offers various DataFrame API's and analytic functions that enables users to process the data and run analytics on the data. While doing so, teradataml internally creates various database objects (Views and Tables) on Vantage, whenever and wherever necessary. All these internally generated views and tables are temporarily created and have a session wide scope. At the end of the session, these views and tables will be removed by teradataml. teradataml GarbageCollector takes care of cleaning up these internally created views and tables.

When a Garbage Collection is performed, cleanup is performed for:
  • Current Session:

    When a user ends a session, Garbage Collection of current active session is done. All temporarily created objects within that session are removed.

  • Old stale or inactive Python sessions:

    GarbageCollector also performs cleanup for other terminated Python sessions for which cleanup was not done properly due to abrupt interruption in the session.

Garbage Collection is triggered automatically upon execution of the following function calls.

  1. remove_context

    This API must be called when user wants to end the current session.

    Calling this API triggers the Garbage Collection to cleanup objects from current session as well as old inactive sessions.

  2. create_context

    This API must be called when either user wants to create a new connection or wants to overwrite the existing context.

    Calling this API also triggers Garbage Collection. When a new context is created, Garbage Collection is performed for the objects created by teradataml in an old, abruptly terminated Python sessions. If a context is being recreated, then Garbage Collection is performed for objects created in previous context and objects created by old abruptly terminated Python sessions.

  3. set_context

    When this API is used, old context is overwritten.

    Calling this API triggers Garbage Collection for current context being overwritten and old inactive sessions.

  4. At Session Exit

    At the end of the session, if you issue quit(), then Garbage Collection is performed.

  • Teradata recommends calling remove_context to end a teradataml session so that cleanup is done properly.
  • GarbageCollector uses the current context to perform Garbage Collection of intermediate views and tables.

    If the connecting user does not have permission to drop the views and tables from old inactive sessions, then those sessions are not cleaned up.

  • GarbageCollector does not remove the objects created by teradataml from different client. It only attempts to remove the objects created by the same client.
  • While using Jupyter notebooks, if session is abruptly terminated, even though session is inactive, cleanup is not done until the kernel responsible for the Python session is shutdown. Same case is applicable for directly closing the notebook. Hence, user should close the notebook only after calling remove_context at the end.