[JAVA-2601] find(Filters.regex("bad field","anything")) Returns Records from Wrong Collection!! Created: 15/Sep/17  Updated: 27/Oct/23  Resolved: 20/Sep/17

Status: Closed
Project: Java Driver
Component/s: Query Operations
Affects Version/s: 3.4.0
Fix Version/s: None

Type: Bug Priority: Critical - P2
Reporter: James Schatzman Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Centos 6.8 and Java 1.8.0_66. Java driver version 3.4.2. Mongodb server version mongodb-linux-x86_64-rhel62-3.4.5. Not sure why 3.4.5 is not an option for "affects versions".



 Description   

This 3.4.5 db has a number of collections (about 10). When I query a collection by

mycollection.find(Filters.regex("field","anything matching")) 

against one collection, I generally get valid records from the WRONG COLLECTION if "field" is not actually a field of the documents in the chosen collection. If "field" is a valid field, or if I use eq instead of regex, this does not happen.

I would expect to get no matches if "field" is not present in the documents in the collection referred to by "mycollection".

Short of adding a lot of code to verify that only "field" names are used that are actually in the documents, I don't see any way to fix this problem. Please help!



 Comments   
Comment by Jeffrey Yemin [ 20/Sep/17 ]

Thanks for the feedback, and glad to hear that the mystery is solved.

Comment by James Schatzman [ 20/Sep/17 ]

Indeed, building the 3.5.0 drivers from source worked fine, and there was no change.

One comment: the website suggests that you can download the tgz or zip archive and build from there, but actually the build script fails if you do it this way. If you clone the repo, then the build script works fine.

This was entirely my goof and I apologize for wasting your time. Apparently, a rogue application put some bad data in the subject Collection. When I dumped the data in the mongo command line tool (with find()), I failed to scroll down far enough to see the bad data.

It turns out that the bad records had the field in my regex that I was expecting to be non-existent. Mystery solved!

Comment by Jeffrey Yemin [ 16/Sep/17 ]

See http://mongodb.github.io/mongo-java-driver/3.5/driver/getting-started/installation/ for installation instructions. If it's not clear, please let us know.

I highly doubt though that this is a bug in the 3.4 driver that was fixed in 3.5.0 or a bug in the 3.4.5 server that was fixed in 3.4.9. I'd focus on collecting the requested logs.

Comment by James Schatzman [ 16/Sep/17 ]

I am going to try the 3.5.0 Java drivers - once I find a working version! The Maven binary repo referenced on the mongoDB website is incomplete and unusable (it is missing all the "core" class files). The source download does appear to be complete. I will try building from source and let you know what I find out.

If that doesn't change anything, then I will try using the 3.4.9 server.

Once I figure out how to turn on logging I will post the requested data.

Comment by Jeffrey Yemin [ 15/Sep/17 ]

I've never seen anything like this. To figure out what's going on please attach mongodb server logs at a high enough verbosity that the queries appear in the logs, and indicate the relevant log lines.

Please also supply the name of the collection that the application is querying against, and if possible the collection from which it appears to be returning documents.

If you can supply a reproducible test case, all the better.

Generated at Thu Feb 08 08:57:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.