I have a java app that has multiple instances over a local network. It uses Redis Redlock to manage integrity of a shared database. Issue here is this java app is still highly unstable so that it crash lot of times. When one instance crashed and it held the lock at the time of crash all other instance get stuck. My question is can I release a lock from a Redis CLI when an instance of Java app which hold the lock crashed.
With the CLI I could remove lock from Redis server with command
DEL <lock name>
When doing so the waiting thread could acquire the lock. I don't know this is the right way. But it works.
Related
Related to this question: Remove lock on environment at every transaction end and How does Jetbrains YouTrack server scales over load?
What can be done to implement a way for Xodus Lock Mechanism to work even with non-graceful application shutdown? For instance, if the application process (which opened write access to a Xodus environment) is killed, the lock remains and the new application process cannot write to the database anymore due to the .lck file, so a manual find . -name "xd.lck" -type f -delete needs to be executed to make it work again.
Additionally, this is true also with multi-process servlet containers/servers which spawns multiple processes of the same application. So the question, how can Xodus Locking mechanism play well with these scenarios?
The lock is immediately released after "the application process (which opened write access to a Xodus environment) is killed".
I have number of java process running on my machine. I need to track how many times each process is getting restarted.
For Example:
Let us consider two java process
Process 1 - Its restarted for 5 times.
Process 2 - Its restarted for 2 times.
I'm able to get the PID, java command of the running processes. But I could not able to differentiate once the process got restarted. Because the PID changed after the restart. Also I can't consider the java command because two instance of same application which has same command.
So what are the other ways to track the java process restart ?
You want your processes to keep the same identity after a restart. Ideally, you would have a parameter, system property or environment variable telling the process its identity.
As you state in the question, this identity cannot be passed on the command line. Thus, the process has to "find" its identity by acquiring an exclusive resource.
This resource could be a shared system implementing locks but it is probably to complex.
As exclusive resources, we have network sockets. So you could make your processes artificially opening a socket in the sole objective to make it acquire an identity.
You can use the code from https://stackoverflow.com/a/116113/2242270 in order to open a socket in a range. The identity of the process is then the port that could be opened.
I am running on a scenario where a NoSQL DB(MongoDB) will hold a record of success or failure status of a certain task and if a task is in failed state, my java scheduler application will read the status,retry and will try to execute the task once again and if task completes successfully, will update the DB record as 'success' state or 'fail' state if failed again.
Now the problem is, my application is deployed in two different nodes(so basically 2 different jvm) and both the nodes share the common NoSQL DB.At a certain point, one scheduler thread wakes up,read the DB and retries for failed tasks and before it completes its execution, another application thread from different node read DB record and and re-executes the task once again which override the previous successful data record update causes unexpected results. So in short, i am running through a race condition and i do not have control over NoSQL DB lock but I want to control at application level.
How do I prevent my application from reading the record which is already been under process by another jvm thread ??
Your suggestions will be greatly appreciated.
I am using jongo library version 1.2 and jdk 1.8
I am writing a client-server application using Java-RMI. Some server-side ressources have to be accessed in mutual exclusion (I am using locks for that purpose).
Now I was wondering what happens when:
The client calls a remote method on the server
The remote method acquires a lock for a critical section
The client crashes before the remote method exits the critical section
Will any locks acquired by the remote method call associated to that client be released? Or will it just be impossible for other clients to acquire the lock afterwards?
Thanks for your answers
What happens is that the remote method keeps executing until it is done, and releases the locks when it exits the critical section. Then it attempts to return the results (if any) to the client, and fails because the connection has been broken.
There is no particular hazard here ...
Of course, if the server is using Lock objects rather than primitive locks / mutexes, then it needs to do the lock releases in a finally block to deal with the case where it fails due to some unexpected exception. But this is a different issue. The client crashing won't trigger that scenario.
I'm trying to use the 8 threads from my new processor to handle transactions on the PostgreSQL database. It have to process geographic data in PostGIS, what I already do with just 1 processor core (one thread). I'm using Java (JDBC4) to create one Connection for each thread. Each connection receives the job to process groups of geometric entities, where one SELECT and one UPDATE statements are used for each entity. Each entity is processed by unique ID and no relation functions are used, so there is no dependencies between the transactions.
The application can be started to run with a variable number of threads. When I run it, all except one of the threads hang. Even if I try to run with just two threads, one hangs. With the "Server status" tool from pgAdmin3 I can see that all the hanging threads are "IDLE in transaction", some in "ExclusiveLock" mode, some in "RowExclusiveLock" mode and some in "AccessShareLock" mode.
I've adjusted my postgresql.conf as described in http://jayant7k.blogspot.com/2010/06/postgresql-tuning-quick-tips.html
I've tried to put the threads to sleep for a while right after the UPDATE statement with no success.
Why are the locks been created? Is there a way to avoid these locks, once that are no reasons to a query depend on other?
Thanks for any help
Did you set min-pool-size and max-pool-size for JDBC connection?
In your case, minimum should be 8.