Getting this error org.mule.runtime.api.store.ObjectAlreadyExistsException: Object already exists for the key - mule4

I am getting this error on cloudhub "org.mule.runtime.api.store.ObjectAlreadyExistsException: Object already exists for the key".
I am using object store in my application. Where I am checking if the value is available in object store and then store it only if it is not available. I have set the option to "Fail if present" as false, still seeing this error.
How to resolve this?
I observed that this issue is coming only when I am using two workers in cloudhub.
Thanks in advance.
Edited:
Using Object Store connector and mule 4.3.
I am checking in object store using Contains if value exists. If it does then Retrieving the value else Storing it to OS.
Error
Edit2:
ObjectStore in Cloudhub:

The error message indicates that the application is using the default persistent object store. For sharing to multiple workers you should instead use the _defaultUserObjectStore which is in memory. Details are in: https://docs.mulesoft.com/object-store/osv2-faq#how-are-object-store-entries-divided-among-workers

You can try this approach!
Use a retrieve connector and wrap it in Try block. And define it own error handling strategy, in which use store connector in On Error Continue block. What it will do is, first it will try to retrieve the values stored in Object Store. If the keys will be present, respective values will be fetched. If the key is not present, an error will occur which will be handled by the error handler and will store the key to object store.

Related

Cannot load the GraphML file I just saved

I'm using Gremlin Server.
I save the contents of the database in an XML file (GraphML) with this line:
g.io(path).write().iterate()
To load the file I use this line:
g.io(path).read().iterate();
And then I get this error:
connection.js:282
new ResponseError(util.format('Server error: %s (%d)', response.status.message, response.status.code), response.status));
^
ResponseError: Server error: For input string: "-2555865115" (500)
This error is coming from gremlin server.
If I search for this value in the XML file (-2555865115) and I remove the last character (-255586511) then the problem is solved.
Why this happens? How can I fix this issue? The database is always saving a file that I have to fix manually.
If I have to change something in the configuration files of Gremlin Server, can you please tell me which file to modify and how? because I never did that before.
I'm using Gremlin server in my local computer just for testing, without any changes.
EDIT:
I changed conf/tinkergraph-empty.properties to this:
gremlin.tinkergraph.vertexIdManager=ANY
gremlin.tinkergraph.edgeIdManager=ANY
gremlin.tinkergraph.vertexPropertyIdManager=ANY
I restarted, but I get the same error when loading the XML file.
Given that removing the last integer from your numerical value solved the problem, I'd speculate you're hitting a limit; specifically, the lowest value an integer can have.
In Java, that value is -2147483647, and that happens to be the language that the default implementation of Gremlin Server is written in. As such, it's likely that the deserialization process is failing while trying to interpret that value as an integer. Since the value is below the minimum value of an integer, and since the error message talks about it being an input string, Integer.parseInt("-2555865115") is probably the call that's failing behind the scenes.
If Gremlin is both serializing and de-serializing the data, it might be a bug in that implementation, and you might want to file an issue. In the mean time, consider implementing and registering a custom serializer to give yourself more control over how the IO process works.

Get application name that executes specific stored procedure

I want to know the application name that executes a specific stored procedure. We have many applications and all have application name property inside the connection string.
Here I don't exactly know which application calling that stored procedure. I think we can get this by calling APP_NAME() but I don't know the exact query to get the correct application name.
SELECT APP_NAME()
The APP_NAME() is a built-in function to return the 'Application Name' token from the connection string used to set up the current session.
Here is a good article on setting up your connection string appropriately:
http://www.sqlerudition.com/using-a-meaningful-application-name-in-the-oledb-connection-string/
If you don't have control over the connection string, then you will need to use a combination of other session variables such as SESSION_USER() or ##SPID and possibly refer to the dmv called sys.dm_exec_sessions for a full record of what the server 'knows' about the connection.
https://learn.microsoft.com/en-us/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-sessions-transact-sql?view=sql-server-2017
If you want detailed information, i would suggest to use Extended Events by selecting rpc_completed event. For detailed steps..

Determine if Cosmos DB NotFound due to missing collection vs. document

Is there a way to programmatically determine from a DocumentClientException where StatusCode == HttpStatusCode.NotFound whether it was the document, the collection, or the database that was not found?
I'm trying to figure out whether I can implement on-demand collection provisioning and only call DocumentClient.CreateDocumentCollectionIfNotExistsAsync when I need to. I'm trying to avoid calling it before making every request (presumably this adds an extra network roundtrip to every request). Likewise, I'm trying to avoid calling it on error recovery when I know it won't help.
From experimentation with the local emulator, the only field I see varying in these three cases is DocumentClientException.Error.Message, and only when the database cannot be found. I generally try to avoid exception dispatching based on human-readable messages.
Wrong database name:
StatusCode: HttpStatusCode.NotFound
Error.Message: {\"Errors\":[\"Owner resource does not exist\"]}...
Correct database name, wrong collection name:
StatusCode: HttpStatusCode.NotFound
Error.Message: {\"Errors\":[\"Resource Not Found\"]}...
Correct database name, correct collection name, incorrect document ID:
StatusCode: HttpStatusCode.NotFound
Error.Message: {\"Errors\":[\"Resource Not Found\"]}...
I'm planning to use a database with its own offer. Since collections inside a database with its own offer are cheap, I'm trying to see whether I can segregate each tenant in my multi-tenant application into its own collection. Each tenant ends up having a different indexing and default TTL policy. The set of collections is not fixed and changes dynamically during runtime as new tenants sign up. I cannot predict when I will need to add a new collection. There's no new tenant notification: I just get a request that I need to handle by creating a document in a possibly non-existent collection. There's a process to garbage collect unused collections.
I'm using the NuGet package Microsoft.Azure.DocumentDB.Core Version 1.9.1 in a .NET Core 2.1 app targeting a SQL API Cosmos DB instance.
If you look at the Message property in detail, you should see following strings that informs whether 404 Not Found response was generated due to Document vs Collection.
ResourceType: Document
ResourceType: Collection
It's not ideal but you can try to regex this information out of error message.

Query regarding database connectivity in db4o

I'm creating a db4o object (namely Customer.yap) and if it is already created i just insert new objects into the existing object (namely Customer.yap) .
For both these operations i'm just using:
IObjectContainer db1 = Db4oEmbedded.OpenFile(Db4oEmbedded.NewConfiguration(),#"C:\Users\admin\Desktop\Db4oObjectFiles\Components.yap");
try
{
db1.Store(comp1);
}
finally
{
db1.Close();
}
Am i doing it right or is there a separate command to check if the object exists and then insert values or can i use the same code for both the operations meaning db4o automatically checks if the object exists at the specified location if it exists it inserts the objects other wise it creates the object at the specified location and then insert the object.
Please help me
Thanks in anticipation
PS: i'm doing this in the context of web application in asp.net and then there is this thought that is always lurking in my mind. should n't i be using the remote connection rather than storing it in actual physical location, but i could n't just figure it how does someone create and store objects in the context of remote connection. i don't know which parameters to specify namely host, port username and password and i even don't know how does some one create database connection what r the statements one should write in the program to connect to this remote object file.
Please please help me and guide me.
A big thanks to anyone in anticipation
db4o automatically updates the object instead of inserting it but there's a catch: you'll have to keep your object container open. db4o works with a local cache that keeps track of stored objects, but once you call close() on the object container that local cash is gone. If you store a previously persisted after a close() on the object container you'll get a duplicate object (db4o thinks it's a new one). If you really have to close the object container and want to update an object you'll have to query for it on db4o, then update, then call store (and then you can close()).
With regards to how to connect to a remote db4o server please see:
http://developer.db4o.com/Documentation/Reference/db4o-7.12/java/reference/Content/client-server/networked.htm
Best! (good luck!)

Parameter count does not match Parameter Value count

We're getting a server error saying "Parameter count does not match Parameter Value count." Anyone have any idea what this could mean?
Our site's on ASP.NET Webforms running DotNetNuke as a CMS.
I've tried uploading an older version of the web.config file but it doesn't seem to have changed since the error came up. It wasn't in any of our recent module file uploads because I reuploaded the old files from this morning that we changed.
Could any changes in the database cause this or would it have to originate from an error in the code?
Thanks.
Some SQL query or stored procedure has more parameters specified then parameters' values received.
Something like this:
command.CommandText = "EXEC test #a";
command.Parameters.Add("#a", "a");
command.Parameters.Add("#b", "b");
i.e. look at the database scheme. Was it changed? Were stored procedures changed?
I've found that if you are using parameters that have default values, certain libraries can't handle.
For instance, we have an application that uses an older version of Microsoft Enterprise Library Data Access method that allows you to pass parameters as an array.
It fails if the amount of items in the array doesn't match exactly the number of parameters on the stored procedure, regardless if some are 'optional' or not.
In cases like this have to use straight ADO.NET and use the cmd.Parameters.AddWithValues("#parameterName", value)
syntax for the required stored procedure parameters. You will not have to add, when using this method, command parameters for the 'optional' stored procedure parameters.
I had the same problem and I found that it was picking the fields from a temporary cache which was being maintained by MySQLHelper.

Resources