小编Ste*_*ore的帖子

从 RDS postgres 只读副本流式传输大型结果集并且 sqlalchemy 提前终止

我正在尝试使用 SQLAlchemy 运行大型查询,并在设置为只读副本的 Postgres 9.4 RDS 服务器上使用以下代码。

    # self.sa_engine is a SQLAlchemy engine
    with self.sa_engine.connect() as conn:
        conn = conn.execution_options(stream_results=True)

        # pd = pandas
        # self.sql = "select * from mylargetable"
        for chunk in  pd.read_sql(self.sql, conn, chunksize=50000):
            # do stuff, write file, etc....
Run Code Online (Sandbox Code Playgroud)

问题是大约 30-60 秒后我收到以下错误。在此期间,文件正在按预期写入。

TransactionRollbackError: terminating connection due to conflict with recovery
DETAIL:  User query might have needed to see row versions that must be removed.
Run Code Online (Sandbox Code Playgroud)

我在 google 上搜索到的所有内容都表明要在 RDS 中的只读副本上设置以下参数:

hot_standby_feedback=1
max_standby_archive_delay=600000
max_standby_streaming_delay=600000
Run Code Online (Sandbox Code Playgroud)

设置这些参数后,我预计仅当查询运行时间超过 10 分钟时才会出现上述错误,但我在 30-60 …

postgresql amazon-web-services amazon-rds read-replication

7
推荐指数
1
解决办法
3567
查看次数

在Rails中,如何在特定的Rspec测试之前加载所有代码?

我有一些Rspec测试有时会失败并出现错误:Circular dependency detected while autoloading constant.这些测试是多线程的(rufus-scheduler测试),这显然是自动加载代码的已知问题(http://route.github.io/2013/11/13/rails-autoloading.html).

如果我config.eager_load = true在config/environments/test.rb中设置,我可以让测试始终如一地工作.但是,我担心当它变得越来越大时,这将真正减慢我的测试套件的其余部分.有没有办法为我的多线程测试设置这个eager load选项?

Rails 4.1.4

ruby multithreading rspec ruby-on-rails eager-loading

6
推荐指数
1
解决办法
1773
查看次数