SIGKILL

如何解决SIGKILL

我有一个 sql Server 数据库,我正在其中以 parquet 格式迁移到 AWS S3 以构建数据湖。我正在使用 Apache Airflow 使用 DAGS 自动执行此任务。在这种情况下,架构上的每个表都变成了一个 .parquet 文件,这使 S3 成为一个数据湖,从而能够后验地使用 AWS Athena 和/或在 ElasticSearch 中进一步建立索引。

有一些非常大的表,这些表的迁移任务显然我希望它需要更多的时间。对于python,我发现唯一能连接微软sql Server的库是pyodbc,微软官方开发维护。

对于如此大的表(6000 万个寄存器的数量级),使用 cursor.fetchall() 花费的时间太长并导致错误,因为任务似乎被 Airlfow 通过 SIGNALKILL 杀死。

Bellow 是 DAG 有多大的一个例子(只是其中的一部分):

Example DAG for Migration

为了获取给定架构中的所有表,我使用了以下 sql Server 查询

SELECT TABLE_NAME
FROM informatION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG='{}';

在括号中,我使用 Python 中的 .format() 函数插入模式名称并检索表以动态构建 DAG 结构。我已经更改了我的 python 代码以批量获取如此大表中的数据,以尽量减少任何潜在的数据溢出:

def stream(cursor,batch_size=50000):
    while True:
        row = cursor.fetchmany(batch_size)
        if row is None or not row:
            break
        yield row


def fetch_data(query,schema,filename,remote_path,save_locally=False):
    cnxn = pyodbc.connect(driver='Here I Put the ODBC Driver Name',host='Host for de sql Server DB',database='Nameof the DB Schema',user='User for Auth in the DB',password='Pass for Auth in the DB')
    print('Connetciton stabilished with {} ..'.format(schema))

    cursor = cnxn.cursor()
    print('Initializing cursor ...')
    print('Requestin query {} ..'.format(query))

    cursor.execute(query)
    print('Query fetched for {} ..'.format(schema))

    row_batch = stream(cursor)
    print('Getting Iterator ...')

    cols = cursor.description
    cols = [col[0] for col in cols]

    print('Creating batch data_frame ..')
    data_frame = pd.DataFrame(columns=cols)

    start_time = time.time()
    for rows in row_batch:
        batch_df = pd.DataFrame.from_records(rows,columns=cols)
        data_frame = data_frame.append(batch_df,ignore_index=True)
        batch_df = None
        print("-- Batch inserted in %s seconds --" % (time.time() - start_time))
        start_time = time.time()

    cnxn.close()
    print('Connetciton closed ..')
    
    // other code to convert to .parquet and send to S3
    save_to_bucket(data_frame,remote_path)
    return 'FETCHING DATA'

该策略似乎对模式中 96% 的整个表都有效,问题是,正如我之前所说,当表非常大时,大约有 6000 万条记录,任务会运行一段时间,大约30 分钟,但通常在那之后,Airflow 会杀死任务,就像那样。没有连接错误,python 异常或什么都没有。调度程序终端中唯一显示的是:

[2021-04-17 23:03:59,719] {scheduler_job.py:1199} INFO - Executor reports execution of ORTOCLIN_TO_S3.FETCHING_HISTORICORESUMO_DATA execution_date=2021-04-17 20:00:17.426578+00:00 exited with status success for try_number 1
[2021-04-17 23:05:02,050] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs
[2021-04-17 23:10:02,314] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs
[2021-04-17 23:15:02,666] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs
[2021-04-17 23:20:03,226] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs
[2021-04-17 23:25:03,868] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs
[2021-04-17 23:30:04,346] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs
[2021-04-17 23:35:04,853] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs
[2021-04-17 23:40:05,324] {scheduler_job.py:1834} INFO - Resetting orphaned tasks for active dag runs

在任务的 Airflow 日志上,我们只有:

Airflow log for task in which the table is very big

有什么解决方法吗?请帮帮我!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?