[JAVA-1055] Bad $set update of nested fields fails but throws no error Created: 02/Dec/13 Updated: 02/Dec/13 Resolved: 02/Dec/13 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Error Handling |
| Affects Version/s: | 2.11.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Zohar Bar-Yehuda | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows and Linux, used through MATLAB |
||
| Description |
|
Trying to update a nested field of an object that already exists as a value type, will result in an error when executed from the mongo shell: > doc = {t1:null} { "t1" : null }> db.test.insert(doc) > db.test.update( { "_id" : ObjectId("529c58a9642f618ff689a5eb")},{"$set":{"t1.t2":1}}) Trying the same with the JAVA driver (which I access from MATLAB, but I suppose native JAVA would be similar): This fails but returns no error (also other valid fields in doc won't be updated) |
| Comments |
| Comment by Jeffrey Yemin [ 02/Dec/13 ] | ||||
|
No problem. It is confusing... | ||||
| Comment by Zohar Bar-Yehuda [ 02/Dec/13 ] | ||||
|
Yes, it works as expected now. Was using: Changed to MongoClient and now it does return the errors. | ||||
| Comment by Jeffrey Yemin [ 02/Dec/13 ] | ||||
|
Yes, if you use MongoClient instead of Mongo, it will by default report all errors. Are you saying that it's not doing that? | ||||
| Comment by Zohar Bar-Yehuda [ 02/Dec/13 ] | ||||
|
You're correct, it's a write concern issue. The above doesn't return an error neither (returns N/A in the WriteResult) This is what I get: m = Mongo{authority=MongoAuthority{type=Direct, serverAddresses=[/127.0.0.1:27017], credentials={credentials={}}}, options=MongoOptions{description='null', connectionsPerHost=100, threadsAllowedToBlockForConnectionMultiplier=5, maxWaitTime=120000, connectTimeout=10000, socketTimeout=0, socketKeepAlive=false, autoConnectRetry=false, maxAutoConnectRetryTime=0, slaveOk=false, readPreference=primary, dbDecoderFactory=DefaultDBDecoder.DefaultFactory, dbEncoderFactory=DefaultDBEncoder.DefaultFactory, safe=false, w=0, wtimeout=0, fsync=false, j=false, socketFactory=javax.net.DefaultSocketFactory@7b58ef06, cursorFinalizerEnabled=true, writeConcern=WriteConcern { "getlasterror" : 1}/ (Continue Inserting on Errors? false), alwaysUseMBeans=false}} And also for my object: ans = WriteConcern { "getlasterror" : 1}/ (Continue Inserting on Errors? false) Doesn't this mean it should return the error unless instructed otherwise? | ||||
| Comment by Jeffrey Yemin [ 02/Dec/13 ] | ||||
|
It's possible that MATLAB is using the default write concern from an old version of the Java driver, which is to not check for errors on updates. To check this theory, are you able to get an error reported for any write error? For example, what happens if you insert the same document twice:
Can you show how the instance of Mongo is created? Can you try doing it like this:
This will use the correct default write concern, which is WriteConcern.ACKNOWLEDGED. |