JacksonDBDecoder - Server errors from MongoDB - mongojack 2.3.0 - mongodb

I have a problem when my application receives an error from MongoDB server, for example:
Imagine that I do a find in MongoDB but the response from MongoDB Server is an error because of a timeout:
{
$err: "MongoTimeout due to...bla bla bla..."
code: 50
}
JacksonDBDecoder is expecting my Java type for example my class "Stuff" (that contains several fields like "price" and "weight"), but when it receives the previous JSON, then there is not any matching fields with "price" and "weight", so the outcome is empty: { }
The empty JSON will be processed by the mongo-java-driver classes (com.mongodb.QueryResultIterator.throwOnQueryFailure exactly) and it will never log the original information "MongoTimeout due to...bla bla bla..." and 50, because the decoder could not understand the JSON from MongoDB Server.
Could you help me to configure mongojack or Jackson to handle this types of responses from MongoDB Server?
Many thanks.
Regards,
Paco.

After talking with MongoDB support, they confirmed to me the following:
"The driver team read our last comments and they believe this is indeed a driver bug. Basically, they think the driver should detect that this is a query failure and use the default decoder to decode the error document rather than the custom decoder registered by MongoJack.
The most relevant part is that this bug does not exist in the 3.x driver series. So our suggestion for you is to upgrade to the 3.2.2 driver (note that MongoJack lists the 3.2 Java driver as its preferred dependency: http://mongojack.org/dependencies.html)."
So, it is not an mongojack issue ;)
Regards,
Paco.

Related

Kafka TimestampConverter not found into confluentinc-connect-transforms-1.4.3

I installed the MongoDB sink connector and the connect-transforms plugin because I would like to convert the value of a field from Unix epoch to Date before to write the data on Mongo but Kafka Connect throws the error
Invalid value class org.apache.kafka.connect.transforms.TimestampConverter for configuration transforms.ttl.t
ype: Transformation is abstract and cannot be created. Did you mean org.apache.kafka.connect.transforms.TimestampConverter$Value, org.apache.kafka.connect.transforms.TimestampConverter$Key?
I had the doubt that there was no concrete class in the plugin, so I downloaded confluentinc/connect-transforms:1.4.3 zip and the TimestampConverter class is missing.
Anyone can help me, please? What I'm doing wrong? Thank you
Did you mean org.apache.kafka.connect.transforms.TimestampConverter$Value, org.apache.kafka.connect.transforms.TimestampConverter$Key?
You cannot have
transforms.ttl.type=org.apache.kafka.connect.transforms.TimestampConverter
You need to set the converter for either the record key or the record value.
Also, this will not change a field within a record. If that is what you wanted, you should ideally change your producer code to do the correct conversion before the Connector consumes the topic, or just handle the conversion in your Mongo queries.
The jars are present at the following co-ordinates. You could include them in the lib when running kafka connect
https://mvnrepository.com/artifact/org.apache.kafka/connect-transforms
The copy source is available at
https://github.com/apache/kafka/blob/trunk/connect/transforms/src/main/java/org/apache/kafka/connect/transforms/TimestampConverter.java

n1ql.delete not working in spring data couchbase

I am using spring data couchbase and I want to write a custom query for deleting all the docs based on some condition
I have below query written down:
#Query("#{#n1ql.delete} WHERE #{#n1ql.filter} AND " +
"accountId = $1 #{#n1ql.returning}")
Mono<Void> delete(String accountId);
But this does not seem to be working. Please help me to fix this issue.
What version are you using?
Please show the calling code and how you determine it does not work.
Two things to check-
If the document to be deleted was just inserted, it may not yet have been indexed.
This is a reactive repository - tbe n1ql wiil not be executed unless the result is collected.

Mongo Java Driver 3.6: Change Streams Codec Error

I'm trying to use the new ChangeStream feature with Mongo Java Driver 3.6, but I'm stuck. This is my error:
ChangeStreamDocument contains generic types that have not been specialised.
Top level classes with generic types are not supported by the PojoCodec.
Here's how I'm starting the changeStream:
CodecRegistry pojoCodecRegistry = fromRegistries(MongoClient.getDefaultCodecRegistry(),
fromProviders(PojoCodecProvider.builder().automatic(true).build()));
MongoDatabase database = mongoClient.getDatabase(mongoClientURI.getDatabase())
.withCodecRegistry(pojoCodecRegistry);
collection.insertOne(Person.builder().age(100).build());
collection.insertOne(Person.builder().age(100).build());
collection.watch().forEach((Block<? super ChangeStreamDocument<Person>>) personChangeStreamDocument -> {
System.out.println(personChangeStreamDocument.getFullDocument());
});
Person is just a POJO.
There's currently a bug with the automatic ProjoCodecProvider as described in JAVA-2800.
The temporary workaround is register the POJO classes manually for example:
CodecRegistry pojoCodecRegistry = fromRegistries(MongoClient.getDefaultCodecRegistry(),
fromProviders(PojoCodecProvider.builder().register(Person.class).build()));
Additionally, please note that you may not be able to see the event insert if you performed the insert operation before you open a change stream on a collection. Although you can test this easily by inserting/altering documents from another thread or process. See also Change Streams for more information.
UPDATE: The ticket JAVA-2800 has been resolved and a fix version is available on MongoDB Java Driver v3.6.4+.

Breezejs - get detailed error message in queries

I am working on an application with ASP.Net/MVC/EF/Breeze/Angular and it is working in my development environment. I just deployed it to my test environment and I am getting an error when I try to query breeze entity data. I don't think it's a DB connection problem, because I can query the breeze metadata successfully.
However, when I try to query for entity data, for example:
http://server/path/breeze/data/Cities
I get the following error:
{"$id":"1","$type":"System.Web.Http.HttpError, System.Web.Http","Message":"An error has occurred."}
This shows up as a 500 error in the browser network history. Is there any way to get Breeze to return a more detailed error message? I am not getting this error in development so I can't debug it there. Or any suggestions as to what I should look for if I can get metadata but not data?
Well, it turns out it was a connection string problem! I have no idea how breeze was generating metadata without a DB connection. Maybe it caches it in a local file?
Anyways, it would be nice to be able to get more detailed messages in cases like this. Since breeze returns IQueryable<T> I couldn't see any obvious way to catch the exception and send back a message myself...

Meteor - Mongo Write error

I am getting an unexpected error when i attempt an update with the latest version of meteor.js. The type error doesn't specify which field it fails on and i am not sure if this is a mongo related issue or not. Has anyone seen this error before?
Error in Mongo write: TypeError: boolean is not a function
I20130901-19:44:56.515(-5)? at writeCallback (packages/mongo-livedata/mongo_driver.js:206)
I20130901-19:44:56.515(-5)? at Meteor.bindEnvironment.runWithEnvironment (packages/meteor/dynamics_nodejs.js:69)
I was able to stop my client from blocking by specifying a callback to the server side call.
https://gist.github.com/warsamebashir/6408451
This usually happens to me when I pass {multi:true} as a second argument to Collection.remove on the server.
You're calling Collection.update with 5 arguments, which is a little bit too many. Read about it in the docs.
I'm getting the same thing on this code:
Templates.remove({_id: {$in: templateIDs}}, {multi:true});
Just for the record, I am still on 0.7.0 and this type of query was working perfectly before the 0.8.1 release. How the hell is it affecting the old 0.7.0 without me even updating is beyond comprehension. Did they change the behavior of remove to now automatically do {multi: true} on everything it finds, because that's what I understood from Peppe L-G's link.
Edit1: Follow-up, yes removing the , {multi:true} fixed the problem, while it still does delete all the matched documents in mongodb. It's either me updating mongodb to 2.4.10 from 2.4.9 or they did an update on the 0.7.0 release that fixes Meteor's behavior.