def get_traceback(db, job_id):
    """
    Return the traceback of the given calculation as a list of lines.
    The list is empty if the calculation was successful.

    :param db:
        a :class:`openquake.server.dbapi.Db` instance
    :param job_id:
        a job ID
    """
    log = db("SELECT * FROM log WHERE job_id=?x AND level='CRITICAL'", job_id)
    if not log:
        return []
    response_data = log[-1].message.splitlines()
    return response_data
