MongoDb 批量保存“isOK() checkWriteError”例外
我正在尝试编写一个解析器,并且使用 MongoDB 作为数据库。本质上它是创建对象,然后保存它们。它每秒会执行多次此操作。保存大约 164 个对象后,它崩溃并出现以下错误:
com.mongodb.MongoException: isOk() at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:130) 在 com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142) 在 com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:141) 在 com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:97) 在 com.mongodb.DBCollection.insert(DBCollection.java:61) 在 com.mongodb.DBCollection.save(DBCollection.java:547) 在 com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:638)位于 com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:685)位于 com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:679)位于 com.soleo.internal.releasenotes.orm.Storage.save(Storage.java:764) 在 com.soleo.internal.releasenotes.page.MainPage$2.onSubmit(MainPage.java:256)
现在,在同一个数据库中,我曾经有超过 1000 个对象,但我只是没有一次将它们全部插入。所以这不可能是硬盘空间的问题。我在网上找不到任何有关此错误的文档。奇怪的是,只有当我尝试保存这个对象时才会出现这种情况。如果我在崩溃后尝试保存对象 B,它保存得很好。它只是在对象 A(我最初批量保存的对象)上崩溃。
我多次进行测试,但在同一个地方失败了。我使用了随机值,这样我就可以证明这不是一个变量问题:
FIRST TRY:
==============================
CREATING RELEASE #162
Component: iHateYou
Location: 250344
Version: 8.8.1.5-2
Date: Sun Feb 07 00:00:00 EST 3188 (02-07-3188)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #163
Component: iHateYou
Location: 227407
Version: 5.5.7.6-7
Date: Sat Mar 04 00:00:00 EST 439 (03-04-439)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #164
Component: iHateYou
Location: 38694
Version: 3.5.4.7-7
Date: Mon Jan 03 00:00:00 EST 158 (01-03-158)
SAVING.............
Oct 28, 2011 11:17:11 AM org.apache.wicket.RequestCycle logRuntimeException
SEVERE: isOk()
com.mongodb.MongoException: isOk()
at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:130)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142)
SECOND TRY:
==============================
CREATING RELEASE #162
Component: iHateYou
Location: 64717
Version: 0.1.0.4-8
Date: Sun May 07 00:00:00 EST 971 (05-07-971)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #163
Component: iHateYou
Location: 19360
Version: 4.5.8.1-3
Date: Wed Aug 04 00:00:00 EST 1339 (08-04-1339)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #164
Component: iHateYou
Location: 115518
Version: 0.0.8.0-2
Date: Sat Apr 07 00:00:00 EST 143 (04-07-143)
SAVING.............
Oct 28, 2011 11:15:28 AM org.apache.wicket.RequestCycle logRuntimeException
SEVERE: isOk()
com.mongodb.MongoException: isOk()
at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:130)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142)
这是一些部分混淆的代码:
Random blank = new Random();
ObjectRef blah = new ObjectRef("iHateYou");
storage.save(blah);
for(int i = 0; i < 300; i++)
{
System.out.println("==============================\nCREATING OBJECT #" + i);
ObjectA saveMe = new ObjectA();
saveMe.setRef(storage.getRefByName("iHateYou"));
System.out.println("Component: " + saveMe.getRef.getName());
saveMe.setLocation(blank.nextInt(300000) + "");
System.out.println("Location: " + saveMe.getLocation());
saveMe.setVersion(new Version(blank.nextInt(9) + "." + blank.nextInt(9) + "." + blank.nextInt(9) + "." + blank.nextInt(9) + "-" + blank.nextInt(9)));
System.out.println("Version: " + saveMe.getVersion());
try
{
String randomDate = "0" + blank.nextInt(9) + "-0" + blank.nextInt(9) + "-" + blank.nextInt(4000);
saveMe.setReleaseDate(new SimpleDateFormat("MM-dd-yyyy").parse(randomDate));
System.out.println("Date: " + saveMe.getReleaseDate() + " (" + randomDate + ") ");
}
catch (ParseException e)
{
e.printStackTrace();
}
System.out.println("SAVING.............");
storage.save(saveMe);
System.out.println("SUCCESS.");
}
I'm trying to write a parser and and I'm using MongoDB as a database. Essentially it is going through, creating objects, and then saving them. It is doing this several times a second. After around 164 objects are saved it crashes with this error:
com.mongodb.MongoException: isOk() at
com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:130)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142) at
com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:141) at
com.mongodb.DBApiLayer$MyCollection.insert(DBApiLayer.java:97) at
com.mongodb.DBCollection.insert(DBCollection.java:61) at
com.mongodb.DBCollection.save(DBCollection.java:547) at
com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:638) at
com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:685) at
com.google.code.morphia.DatastoreImpl.save(DatastoreImpl.java:679) at
com.soleo.internal.releasenotes.orm.Storage.save(Storage.java:764) at
com.soleo.internal.releasenotes.page.MainPage$2.onSubmit(MainPage.java:256)
Now at one point I had over 1000 objects in this same database, I just didn't insert them all at once. So it can't be a hard drive space issue. I can't find any documentation at all of this error online. Oddly it's only when I try saving THIS object. If I try saving Object B after the crash it saves just fine. It just crashes on Object A, the one I initially mass saved.
I ran a test multiple times and it failed in the same place. I used random values so I could prove it wasn't a variable issue:
FIRST TRY:
==============================
CREATING RELEASE #162
Component: iHateYou
Location: 250344
Version: 8.8.1.5-2
Date: Sun Feb 07 00:00:00 EST 3188 (02-07-3188)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #163
Component: iHateYou
Location: 227407
Version: 5.5.7.6-7
Date: Sat Mar 04 00:00:00 EST 439 (03-04-439)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #164
Component: iHateYou
Location: 38694
Version: 3.5.4.7-7
Date: Mon Jan 03 00:00:00 EST 158 (01-03-158)
SAVING.............
Oct 28, 2011 11:17:11 AM org.apache.wicket.RequestCycle logRuntimeException
SEVERE: isOk()
com.mongodb.MongoException: isOk()
at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:130)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142)
SECOND TRY:
==============================
CREATING RELEASE #162
Component: iHateYou
Location: 64717
Version: 0.1.0.4-8
Date: Sun May 07 00:00:00 EST 971 (05-07-971)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #163
Component: iHateYou
Location: 19360
Version: 4.5.8.1-3
Date: Wed Aug 04 00:00:00 EST 1339 (08-04-1339)
SAVING.............
SUCCESS.
==============================
CREATING RELEASE #164
Component: iHateYou
Location: 115518
Version: 0.0.8.0-2
Date: Sat Apr 07 00:00:00 EST 143 (04-07-143)
SAVING.............
Oct 28, 2011 11:15:28 AM org.apache.wicket.RequestCycle logRuntimeException
SEVERE: isOk()
com.mongodb.MongoException: isOk()
at com.mongodb.DBTCPConnector._checkWriteError(DBTCPConnector.java:130)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:142)
Here's some partially obfuscated code:
Random blank = new Random();
ObjectRef blah = new ObjectRef("iHateYou");
storage.save(blah);
for(int i = 0; i < 300; i++)
{
System.out.println("==============================\nCREATING OBJECT #" + i);
ObjectA saveMe = new ObjectA();
saveMe.setRef(storage.getRefByName("iHateYou"));
System.out.println("Component: " + saveMe.getRef.getName());
saveMe.setLocation(blank.nextInt(300000) + "");
System.out.println("Location: " + saveMe.getLocation());
saveMe.setVersion(new Version(blank.nextInt(9) + "." + blank.nextInt(9) + "." + blank.nextInt(9) + "." + blank.nextInt(9) + "-" + blank.nextInt(9)));
System.out.println("Version: " + saveMe.getVersion());
try
{
String randomDate = "0" + blank.nextInt(9) + "-0" + blank.nextInt(9) + "-" + blank.nextInt(4000);
saveMe.setReleaseDate(new SimpleDateFormat("MM-dd-yyyy").parse(randomDate));
System.out.println("Date: " + saveMe.getReleaseDate() + " (" + randomDate + ") ");
}
catch (ParseException e)
{
e.printStackTrace();
}
System.out.println("SAVING.............");
storage.save(saveMe);
System.out.println("SUCCESS.");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来这可能是这个错误的变体: https://jira.mongodb.org/browse/ RUBY-324
您是否使用分片?在这种情况下,您的配置数据库可能已损坏。驱动程序可能不希望收到返回的消息“isOk”。
请告诉我们更多有关您的环境的信息:MongoDB版本、是否使用分片、驱动程序版本等。
Sounds like it could be a variation of this bug: https://jira.mongodb.org/browse/RUBY-324
Are you using sharding? In that case your config DB might be corrupt. The driver is probably not expecting to receive the message "isOk" back.
Please tell us more about your environment: MongoDB version, using sharding or not, driver version, etc.