惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
GbyAI
GbyAI
MongoDB | Blog
MongoDB | Blog
人人都是产品经理
人人都是产品经理
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
量子位
腾讯CDC
Google DeepMind News
Google DeepMind News
Vercel News
Vercel News
Blog — PlanetScale
Blog — PlanetScale
The Register - Security
The Register - Security
博客园 - Franky
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
B
Blog RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Simon Willison's Weblog
Simon Willison's Weblog
Attack and Defense Labs
Attack and Defense Labs
L
Lohrmann on Cybersecurity
S
Schneier on Security
MyScale Blog
MyScale Blog
The Last Watchdog
The Last Watchdog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
PCI Perspectives
PCI Perspectives
博客园 - 聂微东
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
T
Troy Hunt's Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
T
Threat Research - Cisco Blogs
K
Kaspersky official blog
F
Fortinet All Blogs
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
Security Latest
Security Latest
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
B
Blog
有赞技术团队
有赞技术团队
TaoSecurity Blog
TaoSecurity Blog
C
Check Point Blog
Latest news
Latest news
H
Hackread – Cybersecurity News, Data Breaches, AI and More
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Help Net Security
Help Net Security
D
DataBreaches.Net
Google DeepMind News
Google DeepMind News
N
News and Events Feed by Topic
J
Java Code Geeks

博客园 - 12不懂3

IOC容器 分布式锁 分布式事务 Myql索引篇+c#性能优化篇 jwt验证机制 HttpHelper .net7.0 Windos Elastocsearch安装部署汉化 Mysql ElasticSearch C# Common中心目录 ABP.VNET 原书籍《Effective C#:改善C#代码的50个有效方法》 精炼18点 ABP IO读写+Epoll多路复用,计算机底层解析 c# 技术点总结 kuberspere管理工具+k8s安装 K8s核心组件理解 数据库事务和锁
.net升级7.0报错1. MySqlConnection is already in use. See https://fl.vu/mysql-conn-reuse 2.SqlSugar.SqlSugarException: Cannot Open when State is Connecting. 3.The current TransactScope is already complete
12不懂3 · 2023-02-01 · via 博客园 - 12不懂3
  • MySqlConnection is already in use. See https://fl.vu/mysql-conn-reuse

  • SqlSugar.SqlSugarException: Cannot Open when State is Connecting.

  • The current TransactScope is already complete

  • 修复步骤1 SqlSugarSvope先测安全对象可能避免大多数的先测安全问题

    1.SqlsugarClient换成SqlSugarScope(SqlSugarScope要用单列 不然内存会增加)

    2.多租户db.getConnection换成db.GetConnectionScope(AOP也要统一不然时间注册不了)

    钟点:SqlSUgarScope一定要用单列

    步骤1不行继续往下

    修复步骤2 

    1.异步方法不写await 需要db替换成db.CopyNew() 不想加CopyNet就取排查是否有异步async方法  漏写await

    2.task.WhenAll必须要用 task.run(asunc=>await 异步方法) 必须要用task.run 包一层(copynew也可以)

    3.表达使中用比喻 注意action的表达使禁止用异步 需要func<task>这种类型才能用异步 

    第3点错误代码例子data.List.Foreach(async=> it.Button=await GetButtionList())
    需要优化成     
    foreach
    (var item in data.List) { item.Button=await getButtonList(item); }

    简单总结下:SqlSugar会有偶发的线程安全问题,如果遇到了,

    第一步检查有没有漏 await 关键字,

    第二步看方法返回的是不是 Task 类型,void不会进行上下文切换,线程失联就可能出现上面三点异常,

    最后 ForEach 是假异步,除非微软除了 ForeachAsync 否则永远不要用

    sqlsugarclient一旦发生上下文切换就会出现偶发性错误  

    这个上下文是sqlsugarclient上下文 不是线程上下文

    lambda,异步,迭代器这三个东西不要一块写,这个坑MSDN明确说过