- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在执行很多批处理,其中包含准备好的 insert
语句
public static void main(String... args) throws Exception {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
BufferedReader csv = new BufferedReader(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream("records.csv")));
String line;
createConnectionAndPreparedStatement();
while ((line = csv.readLine()) != null) {
tupleNum++;
count++;
List<String> row = new ArrayList<String>(Arrays.asList(line.split(";")));
tupleCache.add(row);
addBatch(row, ps);
if (count > BATCH_SIZE) {
count = 0;
executeBatch(ps);
tupleCache.clear();
}
}
}
protected static void createConnectionAndPreparedStatement() throws SQLException {
System.out.println("Opening new connection!");
con = DriverManager.getConnection(jdbcUrl, jdbcUser, jdbcPassword);
con.setAutoCommit(true);
con.setAutoCommit(false);
ps = con.prepareStatement(insertQuery);
count = 0;
}
private static void executeBatch(PreparedStatement ps) throws SQLException, IOException, InterruptedException {
try {
ps.executeBatch();
} catch (BatchUpdateException bue) {
if (bue.getMessage() != null && bue.getMessage().contains("Exceeded the memory limit")) {
// silently close the old connection to free resources
try {
con.close();
} catch (Exception ex) {}
createConnectionAndPreparedStatement();
for (List<String> t : tupleCache) {
addBatch(t, ps);
}
// let's retry once
ps.executeBatch();
}
}
System.out.println("Batch succeeded! -->" + tupleNum );
con.commit();
ps.clearWarnings();
ps.clearBatch();
ps.clearParameters();
}
private static void addBatch(List<String> tuple, PreparedStatement ps) throws SQLException {
int sqlPos = 1;
int size = tuple.size();
for (int i = 0; i < size; i++) {
String field = tuple.get(i);
//log.error(String.format("Setting value at pos [%s] to value [%s]", i, field));
if (field != null) {
ps.setString(sqlPos, field);
sqlPos++;
} else {
ps.setNull(sqlPos, java.sql.Types.VARCHAR);
sqlPos++;
}
}
ps.addBatch();
}
因此,在独立应用程序中,一切都很好,并且在 700k 批量插入后没有发生异常。但是,当我在大约 6-7k 批量插入后在自定义 Pig StoreFunc
中执行实际相同的代码时,出现以下异常:
java.sql.BatchUpdateException: 112007;Exceeded the memory limit of 20 MB per session for prepared statements. Reduce the number or size of the prepared statements.
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:1824)
只有重新启动连接才有帮助。有人可以帮助我了解为什么会发生这种情况以及如何解决它吗?
最佳答案
根据您的描述和错误信息,根据我的经验,我认为该问题是由SQL Azure服务器端的内存配置引起的,例如服务器资源池内连接的内存限制。
我试图顺着线索寻找有关连接内存限制的具体说明,但没有成功,除了here中的以下内容之外.
Connection Memory
SQL Server sets aside three packet buffers for every connection made from a client. Each buffer is sized according to the default network packet size specified by the sp_configure stored procedure. If the default network packet size is less than 8KB, the memory for these packets comes from SQL Server's buffer pool. If it's 8KB or larger, the memory is allocated from SQL Server's MemToLeave region.
然后我继续搜索packet size
& MemToLeave
并查看它们。
根据以上信息,我猜测“Exceeded the memory limit of 20 MB per session for prepared statements”是指并行连接使用的所有内存超过SQL Azure实例的最大内存缓冲池。
因此,我建议您可以尝试两种解决方案。
BATCH_SIZE
变量的值,使服务器内存消耗小于内存缓冲池的最大大小。希望有帮助。
<小时/>这里有两个新建议。
jtds
jdbc 驱动程序而不是 MS 驱动程序。sqoop
或 kettle
。关于java - Azure:超出了准备语句每个 session 20 MB 的内存限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44188234/
我有一个本地存储库,有一个大文件被意外添加到其中。现在,即时通讯几乎落后了100次提交。当我尝试推送到GitHub时,它给了我一个错误。 我需要做任何我需要做的事情,以便能够推送此存储库的其余部分。
我正在尝试分配内存NSImage*originalLocationImage; NSURL *fileURL = [NSURL fileURLWithPath:originalLocation];//
我如何以及在何处可以编辑CDH4.7中的输入拆分大小,默认情况下为64 MB,但我想将其称为1MB,因为我的MR作业运行缓慢并且我想提高MR作业的速度。我想需要编辑cor-site属性IO.file.
我创建了一个 DLL,其中包含一个从 C# 代码调用的 JNI 函数。作为长时间运行的 GUI 应用程序的 C# 应用程序多次调用该函数。 我的 JNI 函数调用 JNI_GetCreatedJava
运行 TestDFSIO 后,我得到了以下指标: 2019-04-30 09:50:35,790 INFO fs.TestDFSIO: Date & time: Tue Apr
我正在测试连接到 Xcode 5.1.1 的运行 iOS 7.1 的 iPhone 4。我不明白为什么当仪器显示我的应用程序仅使用几兆字节并且有大量可用内存时我会收到内存警告甚至崩溃(见附件)。有什么
我有一个假设的值数据库,每个值的大小为 4 个字节(即 4,000,000,000)。所有值都存在于数据库中,因此它以 0 开头,以最大的 4 字节数字结尾。 只有一次,我想通过将 1 到 10000
我有一个字符串元组的 python 列表,格式如下:lst = [('xxx', 'yyy'), ...etc]。该列表包含大约 8154741 个元组。我使用了一个分析器,它说该列表占用大约 500
我需要每秒发送 1,00,000 批记录。我在实验后得到的是 azure event hub 的事件限制为 10,00,000 个字节。我的每条记录有 145 字节,我必须发送的总记录是 1,00,0
HDFS块大小默认为128 MB(来源:https://hadoop.apache.org/docs/r2.9.0/hadoop-project-dist/hadoop-hdfs/hdfs-defau
我需要每秒发送 1,00,000 批记录。我在实验后得到的是 azure event hub 的事件限制为 10,00,000 个字节。我的每条记录有 145 字节,我必须发送的总记录是 1,00,0
我正在 Linux 机器上运行 Jboss EAP 服务器 6.1。分配的堆内存如下。 JAVA_OPTS="-Xms2048m -Xmx2048m -XX:MaxPermSize=256m -Dja
我最近提出并解决了一个关于将大于 2 MB 的 .PDF 文件作为 BLOBS 上传到 MySQL 数据库的问题。我不得不更改我的 php.ini 文件中的一些设置和 MySQL 的最大数据包设置。然
我需要创建一个文本文件(字母数字),其大小(精确或接近)以 MB 为单位等于我输入的数字,例如 1 MB。我试图生成一个字符串,认为一个字符是 16 位或 2 字节,所以:1KB = 1024 字节
我已经阅读了很多有关通过设置 yarn.scheduler.maximum-allocation-mb 来解决此类问题的内容,我已将其设置为 2gb,因为我当前正在运行 select count(*)
这个问题在这里已经有了答案: this exceeds GitHub's file size limit [duplicate] (3 个回答) 1年前关闭。 核心程序崩溃数据。 我不知道核心文件是从
我已经建立了一个 Electron 应用程序,并使用 Electron 打包程序对其进行了打包。我制作了238MB的Windows bundle 包,而Linux版本是450 MB。我将其与也是 El
这个问题在这里已经有了答案: Generate an integer that is not among four billion given ones (38 个答案) 关闭 9 年前。 Give
我的 Meteor 应用程序获取一个 CSV 文件,使用 Baby Parse(Papa Parse for server)对其进行解析,并将数据插入到 MongoDB 集合中。 每个 CSV 行都作
Amazon SES 有 10 MB 的文件限制 我的问题是 有没有其他方法可以发送超过 10 MB 的文件? 最佳答案 这是一个硬限制。 您需要做的是包含您当前包含在电子邮件中的 Assets 的
我是一名优秀的程序员,十分优秀!