Forums Register Login

How to unlock a record after its been deleted?

+Pie Number of slices to send: Send
Good Evening Guys,

I know I've been posting like crazy here and I thank you for your patience. Im running tight on time. I need to complete the assignment by December 25th and I have yet to submit my code. As a point of interest, how long do Oracle take before they indicate whether or not you need to sit the essay?

Back to my question, what is the standard way to handle deletion of a record?

lock
delete
unlock

If this is so, how can something thats been deleted be unlocked?

G

1
+Pie Number of slices to send: Send
Howd, Glen!

Well, in my case, I had a Map<Integer, Long> where I keep track of what records are locked. The key is the record number, and the value is the id of the client that owns the lock. I also had a Map<Integer, Room> that represented the database records. After deleting a record, its corresponding entry is removed from the Map that represents the database records. And to unlock a record, its corresponding entry is simply removed from the Map that keeps track of the locked records, so there is not problem if it was already deleted.

So everything is handled virtually, in memory. When the application finishes, the Map that represents the database records is flushed to the .db file.

Regarding the essay, when I took this certification, we had to take the essay after submitting the assignment. We just got a voucher for that and scheduled it online in a Prometric center. I think you still have to do it nowadays. For more information, please take a look here.
+Pie Number of slices to send: Send
Hey Buddy,

Thanks for the reply. My difficulty now is, what to do with the threads that are waiting on a record that just got deleted? From your scenario, I think you have come across this issue too.

For example, thread 5 is waiting to lock record 26.
thread 4 deletes record 26.

thread 5 wakes up and checks if the record still exists in

Map<Integer, Long> where I keep track of what records are locked

. If not, it throws a record not found exception.

When I do the above, I see IllegalMonitorExceptions and deadlock sometimes occurrs.

EDIT:The thing is, when I run your test class with updateRandom,Update1,Find and Create, everything runs smoothly. If I run the delete threads too, thats when I see IllegalMonitorExceptions and deadlock.
1
+Pie Number of slices to send: Send
Hi Glen,

IllegalMonitorStateException typically happens when you invoke wait/notify method without holding a lock on that object. Is this the case in your code?

Also, check if you are releasing the locks in 'finally' block. If not done, then it is very typical scenario in which a lock is obtained, and due to some exception, it is never released. This may further lead to deadlock.
+Pie Number of slices to send: Send
Thanks Chaps. You've inspired a comeback.
1
+Pie Number of slices to send: Send
I see you where in good hands when I was enjoying some sun & sea, but now I'm back
+Pie Number of slices to send: Send
 

Roel De Nijs wrote:I see you where in good hands when I was enjoying some sun & sea, but now I'm back



As far as I can tell 99% of the hands around here are good.

I hope your holiday went well. You find me in the middle of doing my choices.txt file. I've been reading through the past pages on this site for ideas of what to include/not to include. I came across your good self's list of contents. Im wondering how high/low level to get?

Do I keept it as a design pattern level or do I go down low and discuss why I used a LinkedHashMap over a HashMap?

Thanks Roel.
1
+Pie Number of slices to send: Send
 

Glen Iris wrote:I hope your holiday went well.


Yes, although the weather was in the 1st half a bit less than expected, I really enjoyed it and had a great time

Glen Iris wrote:Do I keept it as a design pattern level or do I go down low and discuss why I used a LinkedHashMap over a HashMap?


The choices.txt (and the essay exam) are designed to make "sure" that you developed the assignment yourself and not some java whizz kid next door. So the more detailed your information is, the better of course. I mentioned class names, method names and data member names. Both in the decisions document as on the essay exam. So i would opt for low level, of course only appropriate parts. It's useless to discuss the need of every variable and why you chose that particular type.
+Pie Number of slices to send: Send
 

Roel De Nijs wrote:Yes, although the weather was in the 1st half a bit less than expected, I really enjoyed it and had a great time




At least it ended on a high and I bet even the first half was better than Belgium (and Ireland) at this time of year anyway!

Im running at about 3800 words. Do you remember roughly your word count?
+Pie Number of slices to send: Send
 

Glen Iris wrote:I bet even the first half was better than Belgium (and Ireland) at this time of year anyway!




Glen Iris wrote:Do you remember roughly your word count?


No. But I had a quick glance: exactly 5613 words
+Pie Number of slices to send: Send
I used 4934 words. Just to give an indication.
Quantity is not automatically quality

Just show them that you were able of analyzing a problem and solve it a certain way that you can explain.
+Pie Number of slices to send: Send
thanks Dennis.

I think my final count was 4500ish. I had to submit on tuesday evening as I was out of time.I sat the essay yesterday morning. the 6-8 week waiting game begins.in the mean time I have a few threads to tidy up in here.
+Pie Number of slices to send: Send
 

Glen Iris wrote:the 6-8 week waiting game begins.


Based on recent candidate stories, I think you'll get your result much faster than this period.
+Pie Number of slices to send: Send
My guess would be that you don't have to wait 6-8 weeks.
Since the course requirement the amount of participants for this exam has dropped extensively. I submitted somewhere in June and got my result in november. During that time there were a lot of developers who wanted to finish this exam before the course requirement date (and the transition to Oracle and/or PearsonVue was messy at that time).

Next weekend you have your results....at least that would be my wild guess. Until that time...relax and have a beer.

lol roel was faster
+Pie Number of slices to send: Send
 

Glen Iris wrote:I sat the essay yesterday morning.



Good luck, champion! I'm sure you're going to do well on this one
+Pie Number of slices to send: Send
so is there a course attendance requirement now? if so, when did it come in?
+Pie Number of slices to send: Send
I have no idea, because I finished when this requirement didn't exist

But based on this link you have to complete a form which Oracle uses to verify you followed one of the required courses. When you decide to follow one, is completely up to you.
+Pie Number of slices to send: Send
 

Glen Iris wrote:Thanks for the reply. My difficulty now is, what to do with the threads that are waiting on a record that just got deleted?



Hi,

just to give additional value to this topic, I share how I solved the same issue : https://coderanch.com/t/584411/java-developer-SCJD/certification/notify

I remember that it was very hard for me to detect why some deadlocks still occured at the end of my development. The issue is related to some threads waiting for a record that is deleted by the one which owned the lock. What I have done is to call notifyAll() in my delete-method for all threads which are waiting for the lock (1 lock per record is possible in my solution). Once the thread has been awaken, it just raise a RNFE because the record is not in the memory cache anymore.
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1644 times.
Similar Threads
Release or not the lock inside the delete method?
NX Contractors: Requirements Problem. Please Answer!
Locking strategy with singleton
URLyBird Locking
unlock a deleted record, how to?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 06:22:47.