我设置了一个简单的脚本来将新记录插入到 Cassandra 数据库中。它在我的本地机器上运行良好,但是当我将数据库移动到远程机器时,我从客户端收到超时错误。如何正确设置此驱动程序的超时时间?我尝试了很多东西。我在我的 IDE 中破解了超时并让它在没有超时的情况下工作,所以我确信这只是一个超时问题。
我如何设置我的集群:
profile = ExecutionProfile(request_timeout=100000)
self.cluster = Cluster([os.getenv('CASSANDRA_NODES', None)], auth_provider=auth_provider,
execution_profiles={EXEC_PROFILE_DEFAULT: profile})
connection.setup(hosts=[os.getenv('CASSANDRA_SEED', None)],
default_keyspace=os.getenv('KEYSPACE', None),
consistency=int(os.getenv('CASSANDRA_SESSION_CONSISTENCY', 1)), auth_provider=auth_provider,
connect_timeout=200)
session = self.cluster.connect()
Run Code Online (Sandbox Code Playgroud)
我正在尝试执行的查询:
model = Model.create(buffer=_buffer, lock=False, version=self.version)
Run Code Online (Sandbox Code Playgroud)
13. . ': '客户端请求超时。参见 Session.execute_async'}, last_host=54.213。.
我插入的记录是 11mb,所以我可以理解有延迟,只是增加超时应该可以做到,但我似乎无法弄清楚。
如何避免在这里使用/root/.cache?不知道我了解多阶段构建如何工作。
# ---- Base python ----
FROM python:2.7-alpine3.7 AS base
# Create app directory
WORKDIR /app
# ---- Dependencies ----
FROM base AS dependencies
COPY requirements.txt ./
RUN apk add --no-cache libgcc git build-base && \
pip install -r requirements.txt && \
apk del git build-base binutils-libs binutils gmp isl libgomp libatomic pkgconf libgcc && \
apk del mpfr3 mpc1 libstdc++ gcc musl-dev libc-dev g++ make fortify-headers ca-certificates libssh2 && \
apk del libcurl expat pcre2 git && \
pip …Run Code Online (Sandbox Code Playgroud)