[SERVER-20171] Invalid "cannot use the part to traverse the element" Created: 28/Aug/15  Updated: 20/Jul/16  Resolved: 28/Oct/15

Status: Closed
Project: Core Server
Component/s: Write Ops
Affects Version/s: 3.0.6
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Chad Kreimendahl Assignee: Ramon Fernandez Marina
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-15029 $rename modifier uses incorrect dotte... Closed
is related to SERVER-25164 $rename doesn't rename fields with do... Closed
Operating System: ALL
Steps To Reproduce:

The following query on a collection with at least a few hundred documents matching the following fields causes some, but not all, records to be updated.

db.DC_4_Vit.update({},
	{ 
  "$rename" : { 
    "Entity.Fd.495.BeginFasiculation" : "Entity.Fd.495.FDb",
	"Entity.Fd.495.Fasiculated" : "Entity.Fd.495.FDe",
	"Entity.Fd.495.Thing" : "Entity.Fd.495.Er",
	"Entity.Fd.495.PreventFasiculation" : "Entity.Fd.495.PvF",
	"Entity.Fd.560.BeginFasiculation" : "Entity.Fd.560.FDb",
	"Entity.Fd.560.Fasiculated" : "Entity.Fd.560.FDe",
	"Entity.Fd.560.Thing" : "Entity.Fd.560.Er",
	"Entity.Fd.560.PreventFasiculation" : "Entity.Fd.560.PvF",
	"Entity.Fd.562.BeginFasiculation" : "Entity.Fd.562.FDb",
	"Entity.Fd.562.Fasiculated" : "Entity.Fd.562.FDe",
	"Entity.Fd.562.Thing" : "Entity.Fd.562.Er",
	"Entity.Fd.562.PreventFasiculation" : "Entity.Fd.562.PvF",
	"Entity.Fd.618.BeginFasiculation" : "Entity.Fd.618.FDb",
	"Entity.Fd.618.Fasiculated" : "Entity.Fd.618.FDe",
	"Entity.Fd.618.Thing" : "Entity.Fd.618.Er",
	"Entity.Fd.618.PreventFasiculation" : "Entity.Fd.618.PvF",
	"Entity.Fd.1036.BeginFasiculation" : "Entity.Fd.1036.FDb",
	"Entity.Fd.1036.Fasiculated" : "Entity.Fd.1036.FDe",
	"Entity.Fd.1036.Thing" : "Entity.Fd.1036.Er",
	"Entity.Fd.1036.PreventFasiculation" : "Entity.Fd.1036.PvF",
	"Entity.Fd.2467.BeginFasiculation" : "Entity.Fd.2467.FDb",
	"Entity.Fd.2467.Fasiculated" : "Entity.Fd.2467.FDe",
	"Entity.Fd.2467.Thing" : "Entity.Fd.2467.Er",
	"Entity.Fd.2467.PreventFasiculation" : "Entity.Fd.2467.PvF",
	"Entity.Fd.3692.BeginFasiculation" : "Entity.Fd.3692.FDb",
	"Entity.Fd.3692.Fasiculated" : "Entity.Fd.3692.FDe",
	"Entity.Fd.3692.Thing" : "Entity.Fd.3692.Er",
	"Entity.Fd.3692.PreventFasiculation" : "Entity.Fd.3692.PvF",
	"Entity.Fd.27153.BeginFasiculation" : "Entity.Fd.27153.FDb",
	"Entity.Fd.27153.Fasiculated" : "Entity.Fd.27153.FDe",
	"Entity.Fd.27153.Thing" : "Entity.Fd.27153.Er",
	"Entity.Fd.27153.PreventFasiculation" : "Entity.Fd.27153.PvF",
	"Entity.Fd.27156.BeginFasiculation" : "Entity.Fd.27156.FDb",
	"Entity.Fd.27156.Fasiculated" : "Entity.Fd.27156.FDe",
	"Entity.Fd.27156.Thing" : "Entity.Fd.27156.Er",
	"Entity.Fd.27156.PreventFasiculation" : "Entity.Fd.27156.PvF",
	"Entity.Fd.27267.BeginFasiculation" : "Entity.Fd.27267.FDb",
	"Entity.Fd.27267.Fasiculated" : "Entity.Fd.27267.FDe",
	"Entity.Fd.27267.Thing" : "Entity.Fd.27267.Er",
	"Entity.Fd.27267.PreventFasiculation" : "Entity.Fd.27267.PvF",
	"Entity.Fd.27268.BeginFasiculation" : "Entity.Fd.27268.FDb",
	"Entity.Fd.27268.Fasiculated" : "Entity.Fd.27268.FDe",
	"Entity.Fd.27268.Thing" : "Entity.Fd.27268.Er",
	"Entity.Fd.27268.PreventFasiculation" : "Entity.Fd.27268.PvF",
	"Entity.Fd.27429.BeginFasiculation" : "Entity.Fd.27429.FDb",
	"Entity.Fd.27429.Fasiculated" : "Entity.Fd.27429.FDe",
	"Entity.Fd.27429.Thing" : "Entity.Fd.27429.Er",
	"Entity.Fd.27429.PreventFasiculation" : "Entity.Fd.27429.PvF",
	"Entity.Fd.28668.BeginFasiculation" : "Entity.Fd.28668.FDb",
	"Entity.Fd.28668.Fasiculated" : "Entity.Fd.28668.FDe",
	"Entity.Fd.28668.Thing" : "Entity.Fd.28668.Er",
	"Entity.Fd.28668.PreventFasiculation" : "Entity.Fd.28668.PvF",
	"Entity.Fd.28681.BeginFasiculation" : "Entity.Fd.28681.FDb",
	"Entity.Fd.28681.Fasiculated" : "Entity.Fd.28681.FDe",
	"Entity.Fd.28681.Thing" : "Entity.Fd.28681.Er",
	"Entity.Fd.28681.PreventFasiculation" : "Entity.Fd.28681.PvF",
	"Entity.Fd.28682.BeginFasiculation" : "Entity.Fd.28682.FDb",
	"Entity.Fd.28682.Fasiculated" : "Entity.Fd.28682.FDe",
	"Entity.Fd.28682.Thing" : "Entity.Fd.28682.Er",
	"Entity.Fd.28682.PreventFasiculation" : "Entity.Fd.28682.PvF",
	"Entity.Fd.28683.BeginFasiculation" : "Entity.Fd.28683.FDb",
	"Entity.Fd.28683.Fasiculated" : "Entity.Fd.28683.FDe",
	"Entity.Fd.28683.Thing" : "Entity.Fd.28683.Er",
	"Entity.Fd.28683.PreventFasiculation" : "Entity.Fd.28683.PvF",
	"Entity.Fd.28846.BeginFasiculation" : "Entity.Fd.28846.FDb",
	"Entity.Fd.28846.Fasiculated" : "Entity.Fd.28846.FDe",
	"Entity.Fd.28846.Thing" : "Entity.Fd.28846.Er",
	"Entity.Fd.28846.PreventFasiculation" : "Entity.Fd.28846.PvF",
	"Entity.Fd.30153.BeginFasiculation" : "Entity.Fd.30153.FDb",
	"Entity.Fd.30153.Fasiculated" : "Entity.Fd.30153.FDe",
	"Entity.Fd.30153.Thing" : "Entity.Fd.30153.Er",
	"Entity.Fd.30153.PreventFasiculation" : "Entity.Fd.30153.PvF",
	"Entity.Fd.30456.BeginFasiculation" : "Entity.Fd.30456.FDb",
	"Entity.Fd.30456.Fasiculated" : "Entity.Fd.30456.FDe",
	"Entity.Fd.30456.Thing" : "Entity.Fd.30456.Er",
	"Entity.Fd.30456.PreventFasiculation" : "Entity.Fd.30456.PvF",
	"Entity.Fd.30559.BeginFasiculation" : "Entity.Fd.30559.FDb",
	"Entity.Fd.30559.Fasiculated" : "Entity.Fd.30559.FDe",
	"Entity.Fd.30559.Thing" : "Entity.Fd.30559.Er",
	"Entity.Fd.30559.PreventFasiculation" : "Entity.Fd.30559.PvF",
	"Entity.Fd.30580.BeginFasiculation" : "Entity.Fd.30580.FDb",
	"Entity.Fd.30580.Fasiculated" : "Entity.Fd.30580.FDe",
	"Entity.Fd.30580.Thing" : "Entity.Fd.30580.Er",
	"Entity.Fd.30580.PreventFasiculation" : "Entity.Fd.30580.PvF" 
    } 
  },
	{multi: true});

Participants:

 Description   

When attempting to rename fields on all documents in a collection, we're seeing a strange occurrence of this error message that only happens on collections with certain kinds of data. The error only happens when doing an update with multi: true

It updates some of the documents, a seemingly random number. Performing a restore of the collection and rerunning the query causes the same error, but different records to be updated.



 Comments   
Comment by Ramon Fernandez Marina [ 28/Oct/15 ]

sallgeud, we haven't heard back from you for some time so I'm going to resolve this ticket. Since the error message indicates that there was at least one document where Entity was null when the command was run and there's insufficient evidence to point to a bug in the server the behavior you're seeing is expected.

Regards,
Ramón.

Comment by Ramon Fernandez Marina [ 09/Oct/15 ]

sallgeud, the error message you provided:

cannot use the part (Entity of Entity.Fields.495.BeginCalculation) to traverse the element ({Entity: null})

means there was at least one document where Entity was null when the command was run.

If that's not the case and you continue to get this error message we'll need to look at your data to determine if there's a bug triggered by your specific dataset and/or operations. I've created an upload portal for you where you can, privately and securely, upload a dataset that reproduces the issue.

Thanks,
Ramón.

Comment by Chad Kreimendahl [ 09/Oct/15 ]

None of the entity objects were ever null and are not null today either.

Comment by Scott Hernandez (Inactive) [ 09/Oct/15 ]

Chad,

The behavior you are seeing is due to the "Entity" field being explicitly null, or really any type which is not an embedded document. Let me give you a slightly different repro/example:

> db.r.save({_id:1, a: 245})
> db.r.update({}, {$rename:{"a.b.c": "a.b.d"})
WriteResult({
	"nMatched" : 0,
	"nUpserted" : 0,
	"nModified" : 0,
	"writeError" : {
		"code" : 16837,
		"errmsg" : "cannot use the part (a of a.b.c) to traverse the element ({a: 245})"
	}})

In order to ensure you don't get errors like this, I'd suggest making sure your "Entity" field is either not there, or an embedded document ({}) so that it is compatible with dot-notation in rename.

I'm guessing that at some point that some of your documents "Entity" field explicitly to null, and maybe not intentionally, which is very different than removing the field (with $unset), or keeping it as an empty embedded document ({}).

I hope this helps clears up the current behavior and why you got an error while running your rename.

--Scott

Comment by Chad Kreimendahl [ 31/Aug/15 ]

1) exception: cannot use the part (Entity of Entity.Fields.495.BeginCalculation) to traverse the element (

{Entity: null}

) code:16837
2) You'll get the failure on any document which does not have the Entity property in the root
3) Other than connections, these are the only errors
4) I verified it existed in the shell as well.

The current workaround to this is to ensure that every object we're updating as "Entity". So we were able to temporarily work around this by only updating records with Entity: {$exists: 1} However, we don't always know that we're reliant upon the same document property when doing this, when we may be updating hundreds of names.

Comment by Sam Kleinman (Inactive) [ 31/Aug/15 ]

Thanks for the report. Could you please answer the following questions about your configuration to help us with the debugging process.

  1. Could you please provide the complete error message that you're seeing? Does the modification fail on all documents or just some?
  2. Do you have a a sample document that we can use to reproduce this issue in our own environment?
  3. If you have logs collected for the time when you ran this operation, could you also attach the relevant section of the logs to this ticket?
  4. I want to confirm that this issue is present in the mongo shell, in addition to the driver or client that your application uses?

Thanks again.

Regards,
sam

Generated at Thu Feb 08 03:53:23 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.