当前位置:网站首页>The flare project celery uses the pits encountered in redis sentinel
The flare project celery uses the pits encountered in redis sentinel
2022-07-24 00:58:00 【Sindweller5530】
flask project celery Error reported in Can’t reconnect until invalid transaction is rolled back
Found to be celery There is one place in the procedure of db.session.commit() No exception was handled , add to try except InvalidRequestError and db.session.rollback() After the repair . It's been SQLAlchemyError.
celery The database connection pool size limit in and the connection is not released
QueuePool limit of size 10 overflow 10 reached, connection timed out
The database connection used after query has not been released .
Solution : Automatically release the connection .
Reference resources :https://stackoverflow.com/questions/24956894/sql-alchemy-queuepool-limit-overflow
@app.teardown_appcontext
def shutdown_session(exception=None):
db.session.remove()
In addition, increase the size of the database connection pool .
celery+flask+redis+sentinel How to configure and initialize with password
Set directly at the beginning REDIS_URL = "sentinel://:[email protected]:26379/0" Report errors :
ValueError: Couldn't import 'app.celery': Redis URL must specify one of the following schemes (redis://, rediss://, unix://)
Thought it was celery, But this is actually initialization redis-client What happened .
take redis_client Initialization of from Flask-redis Change it to redis.sentinel
# redis_client = FlaskRedis(app)
redis_client = Sentinel([('localhost', 26379)], socket_timeout=1, sentinel_kwargs={
'password': 'password'})
print(redis_client.discover_master("mymaster"))
# Example of print results :
# ('10.1.1.1', 6379)
# redis Use examples
That's it redis, Then solve it later celery Of broker and result backend Configuration of
(mymaster Is the default primary cluster )
BROKER_URL = "sentinel://:[email protected]:26379/1"
BROKER_TRANSPORT_OPTIONS = {
'master_name': 'mymaster',
'socket_timeout': 1,
'sentinel_kwargs': {
'password': 'password'}
}
CELERY_RESULT_BACKEND = "sentinel://:[email protected]:26379/2"
CELERY_RESULT_BACKEND_TRANSPORT_OPTIONS = BROKER_TRANSPORT_OPTIONS
边栏推荐
- Prometheus+node exporter+grafana monitoring server system resources
- How to use SAP intelligent robotic process automation to automate Excel
- SAP 电商云 Spartacus UI Store 相关的设计明细
- Focus on microservices
- vim常用命令
- Establishment of static route
- 【LeetCode第 83 场双周赛】
- An article teaches you the basic use of kubernetes
- Tutorial on principles and applications of database system (052) -- data integrity of MySQL (XIV): crosstab query (row column conversion)
- Client does not support authentication protocol requested by server; consider upgrading MySQL client
猜你喜欢

NOTICE: PHP message: PHP Warning: PHP Startup: Unable to load dynamic library ‘*****‘

【LeetCode第 83 场双周赛】

網絡系統實驗:ping不通的問題解决

What is the function of the select... For UPDATE statement? Can you lock tables or rows?
![[the 83rd fortnight of leetcode]](/img/41/411dc235a34f9dde06a41323628648.png)
[the 83rd fortnight of leetcode]

docker mysql

黑马程序员-接口测试-四天学习接口测试-第四天-Postman读取外部数据文件,读取数据文件数据,iHRM项目实战,员工管理模块,添加员工,批量运行测试用例,生成测试报告,

Bean Validation使用篇----05

Easy gene | target gene DNA methylation sequencing (target BS)

Memory forensics nssctf otterctf 2018 (replay)
随机推荐
AVX instruction set accelerated matrix multiplication
Modify node temporarily_ Modules package source code and compile reference to modify dependent packages
Bert article translation
Creo 9.0 mouse button operation for model observation
Centernet target detection model and centerfusion fusion target detection model
Deep understanding of collaborative process
Sword finger offer frog jumps stairs
工作3年的测试员跳槽后工资是原来的2倍,秘诀原来是......
postman测试接口在URL配置正确的情况下出现404或者500错误
JS determines whether the element scrolls to the top
MySQL exercise: all employees reporting to the CEO
The way to access global variables in multi-source file mode (extern usage)
【複盤】關於我在錯誤的時間選錯了技術這件事
Development of main applet for business card traffic near the map
Hcia-01 initial understanding of the Internet
GLIB-CRITICAL g_ file_ test:assertion ‘filename != null‘ failed
Notes and Thoughts on the red dust of the sky (VI) due to lack
There are various signs that apple is expected to support AV1
Educational Codeforces Round 132 (Rated for Div. 2) D. Rorororobot
Thread pool summary