C# 数据库写入Sql Bulk索引损坏异常问题System.InvalidOperationException: DataTable internal index is corrupted: '4'
C# 数据库写入Sql Bulk索引损坏异常问题
System.InvalidOperationException: DataTable internal index is corrupted: '4'
这几天发现数据库写入时报了这样的一个异常出来,之前从未出现过的,网上搜索了一下,多数是提到4个原因:
引用自:https://stackoverflow.com/questions/450675/datatable-internal-index-is-corrupted
Here are reasons that I know how DataTable internal index is corrupted: '' happens. ) Changing values during DataView.ListChanged event. This is not supported. Look at the callstack and if you see DataView.OnListChanged and you are changing a DataRow/Set/Table, then index corruption will likely happen (i.e. thrown from DataRow.EndEdit) Short description of the problem: the internal indexes getting notified of the edits out-of-order. Workaround - use the DataTable.RowChanged event instead of the DataView.ListChanged. ) There is still an unfixed bug when merging data into an existing DataRow that starts in the Added or Deleted state and ends in the Modified row state. DataAdapter.Fill, DataSet.Load, DataTable.Load when LoadOption.PreserveChanges. DataSet.Merge, DataTable.Merge deleted rows. DataSet.Merge(DataRow[]) for added rows. Short description of the problem: The DataTable tells the DataView to “add” instead of “change”, resulting in index corruption. ) multi-threading The DataSet/DataTable and any connected objects are not thread safe. Make sure you lock all the appropriate objects. ) When the DataColumn.DataType is a reference type and the values are being changed instead of being treated as read only.
Example: DataColumn.DataType is byte[] and the column sorted. If the values in the byte array are changed instead of assigning a new byte array to the DataRow, the internal index doesn’t know about the change and becomes corrupt. This is data being changed without the internal index being notified.
因为我的代码用了多线程,猜测可能是由于这个原因,但是通过写测试代码测试,1000个线程不加锁来写,也没有这样问题存在。
折磨了几天后,又仔细看了下异常信息,用再接近报错代码的地方的信息搜索了下
at System.Data.RBTree`1.GetNewNode(K key)
at System.Data.DataTable.SetNewRecordWorker(DataRow row, Int32 proposedRecord, DataRowAction action, Boolean isInMerge, Boolean suppressEnsurePropertyChanged, Int32 position, Boolean fireEvent, Exception& deferredException)
at System.Data.DataTable.InsertRow(DataRow row, Int64 proposedID, Int32 pos, Boolean fireEvent)
发面,按这个搜索的结果,就是和内存相关了,OutOfMemoryException,于是运行程序看了下内存,终于发现问题了,跑到高峰时,内存暴满了。
http://www.databaseforum.info/1/1/ec1879c1a0b65ca3.html
瀑汗啊!! 原来是内存崩溃造成的索引损坏!
C# 数据库写入Sql Bulk索引损坏异常问题System.InvalidOperationException: DataTable internal index is corrupted: '4'的更多相关文章
- 异常:System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms FIPS信息标准限值了MD5加密
最近做的winform项目中,有个功能使用了MD5 加密,本地测试是没有问题的,但是上线后有些用户反馈说提示如下错误 一.问题描述 中文版错误截图 英语版错误截图 具体错误信息: 有关调用实时(JIT ...
- 异常:System.InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms 这个实现是不是Windows平台FIPS验证的加密算法。解决方法
遇见这个问题是在使用了MD5加密算法后报错的,可能的原因如下: 1.FIPS不兼容MD5,此时需要修改注册表 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\C ...
- EF异常:“System.InvalidOperationException”类型的未经处理的异常在 mscorlib.dll 中发生
实体框架System.Data.Entity.SqlServer提供者类型”. SqlProviderServices EntityFramework. 的在应用程序配置文件注册状态"置疑 ...
- 关于DataTable内部索引已损坏的问题 System.Data.RBTree
1.错误提示: 最近,Winform程序在极其偶然的情况下会遇到如下错误提示 Framework 版本: v4.0.30319 说明: 由于未经处理的异常,进程终止. 异常信息: System.Inv ...
- redis数据库写入数据时提示redis.exceptions.ResponseError错误
今天运行Django项目在redis数据库写入数据时提示如下错误: ERROR log 228 Internal Server Error: /image_code/cf9ccd75-d274-45c ...
- sql2005数据库置疑修复断电崩溃索引损坏 数据库索引错误修复/数据库表损坏/索引损坏/系统表混乱等问题修复
sql2005数据库置疑修复断电崩溃索引损坏 数据库索引错误修复/数据库表损坏/索引损坏/系统表混乱等问题修复 客 户 名 称 济南某电子商务公司 数 据 类 型 SQL2005数据库 故 障 检 测 ...
- SQL 撤销索引、表以及数据库
通过使用 DROP 语句,可以轻松地删除索引.表和数据库. SQL DROP INDEX 语句 我们可以使用 DROP INDEX 命令删除表格中的索引. 用于 Microsoft SQLJet (以 ...
- SQL 撤销索引、撤销表以及撤销数据库
SQL 撤销索引.撤销表以及撤销数据库 通过使用 DROP 语句,可以轻松地删除索引.表和数据库. DROP INDEX 语句 DROP INDEX 语句用于删除表中的索引. 用于 MS Access ...
- [SQL SERVER] - 还原数据库备份(SQL脚本),抛出 "System.OutOfMemoryException" 异常之解决
背景 在 Microsoft SQL Server 2016 的查询窗体中,直接还原备份数据库的 SQL 脚本(99MB),抛出 Cannot execute script 异常: 原因 相关资料说: ...
随机推荐
- iOS开发之WIFI,3G/4G两种网络同时使用技巧
最近遇到一个比较奇葩的需求:App与硬件通过WiFi LAN通信, 同时App需要与服务器通过3G/4G WAN通信,如下图: 众所周知,手机同时打开WiFi和3G时候,会优先走WiFi.这个该如何实 ...
- VueJS坎坷之路111---_self.$scopedSlots.default is not a function
VueJs + Element 话不多说,直接贴错: _self.$scopedSlots.default is not a function <el-table stripe border r ...
- Confirm the Ending--freecodecamp算法题目
Confirm the Ending(检查字符串结尾) 要求 判断一个字符串(str)是否以指定的字符串(target)结尾. 如果是,返回true;如果不是,返回false. 思路 利用.repla ...
- ANSI C 与 K&R C
C语言由Dennis M.Ritchie在1973年设计和实现.从那以后使用者逐渐增加.到1978年Ritchie和Bell实验室的另一位程序专家Kernighan合写了著名的<TheC Pro ...
- 【线性基】bzoj2844: albus就是要第一个出场
线性基求可重rank 题目描述 给定 n 个数 $\{ a_i \}$ ,以及数 $x$. 将 $\{ a_i \}$ 的所有子集(包括空集)的异或值从小到大排序,得到 $\{ b_i \} $. ...
- redis学习笔记(2)
redis学习笔记第二部分 --配置文件介绍 二,解析redis的配置文件redis.conf常见配置参数说明redis.conf 配置项说明如下:1. Redis默认不是以守护进程的方式运行,可以通 ...
- (68)zabbix windows性能计数器使用详解
概述 windows下的性能计数器让zabbix监控更加轻松,直接获取性能计数器的数值即可完成windows监控.性能计数器如下: 1 perf_counter["\Processor( ...
- 【Shiro】调用doGetAuthenticationInfo进行认证成功之后,isAuthenticated是false的问题。
使用@Configuration配置shiro无状态登录时出现的问题,在subject.login之后当前线程重新绑定了一个假定subject,isAuthenticated. 这里自定义的访问拦截器 ...
- python 类的封装/property类型/和对象的绑定与非绑定方法
目录 类的封装 类的property特性 类与对象的绑定方法与非绑定方法 类的封装 封装: 就是打包,封起来,装起来,把你丢进袋子里,然后用绳子把袋子绑紧,你还能拿到袋子里的那个人吗? 1.隐藏属性和 ...
- TCP的三次握手和四次握手
三次握手(建立连接) 首先,服务器进程(B)先创建传控制块TCB(用来存储连接信息,如连接表,发送和接收序号等),准备接收客户进程(A)的请求.然后服务器进程处于LISTEN(收听)状态,等待客户的连 ...