- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
well you are not "competant" speller.. that's for sure :)
Admin
Admin
On the 3 day God inventented MySQL 3, thus his lack of transactions.
Admin
There should be 2 more
lock level -0.5 = probably not locked lock level 0.5 = probably locked lock level 0.9 = locked for sure
Admin
lock level 8 = true
lock level 9 = false
lock level 10 = lock level 2
Admin
Dont forget the way lock work on windows file systems!
Level 1: Lock, you cant remove the file but you can write on it
Level 2: Everyone can write on it.
Admin
Surely no need for a separate recursion setting, db__locks had a row for every table, presumably including itself.
I assume that's how they got round the race condition in the code snippet. We just weren't shown the surrounding code which locked db__locks
Admin
lock level 8 = locked and loaded
lock level 000089 = pad lock
lock level 60 = LFG
Admin
Yeah... And some of the words have more than one syllable. ;-) I don't see a problem with the length of any of the posts.
Admin
lock level 9 = admin lock
lock level 9 = not admin lock
lock level 9 = Sunday
Admin
Reading through the anti patterns on wikipedia, I found a big WTF in the explanation of http://en.wikipedia.org/wiki/Sequential_Coupling
The author suggests that "A class should be like an automobile so that if the user steps on the gas without starting the engine... nothing happens. It should not throw an exception, crash, or fail."
So... a function should just return without doing anything or telling the user that it failed. I guess it's not important to tell the user that the transfer_money() function didn't work because they hadn't called authorize_transaction() first?
Admin
Admin
I've implemented a "check out" table before.. where a user checks out an item, and everyone else sees that it is checked out. You can "un check out" an item or have it expire based on a timestamp
Admin
To beat this topic to death some more, and I can't believe no one posted it yet:
lock level 42 = lock The Universe
Admin
lock level 12345: Hey, that's my luggage!
Admin
If only I wasn't using the original Dungeons and Admins system. I hate calculating my TULC0 (to unlock lock class zero).
Admin
True. Though I was thinking that you might need to get over the other side of the railway lines somehow (assuming that you haven't built your railway along the sea). In your diagram that requires some kind of additional crossing.
That said, with the "outer platform" scenario, one of the platforms is typically not accessible from the street. Though this is a business decision and not a requirement of the design. One station I know of (with outer platforms) has a pedestrian bridge outside of the station and another bridge inside of the station (When it gets late, they open a gate on the non-ticket-office platform so people can get to the overflow car park without having to use both bridges).
When is today's WTF coming out anyway?
Rich
Admin
I hate locks.
Unfortunately, sometimes users will pull up a screen of data and leave it there for a while before changing and submitting it. This means that they could overwrite someone else's update.
The solution I used at one place wasn't the most elegant, but it solved the problem, didn't leave locks lying around, and wasn't spread out among multiple stored procedures.
The app that submitted the change back to sql passed both the original data and the updated data to the stored proc.
The stored proc compared the original data to the existing record. If the field the user was changing didn't match, it returned the error back to the app so that the user would know.
If the record was changed but the relevent field hadn't been modified, it was ok generally. This part depended on what data obviously.
Admin
After that, I sure hope you'd quit, just to drive home the point.
</sarc>Admin
Can i CRY after having read this? If this was one of my employees I would punch him/her in the face.
Admin
Where would you need above described scenario?
Admin
This code just has it all. Semi-active waiting, race conditions (as has been mentioned) and deadlocks too because SPs can't agree on the order in which they acquire locks and/or some locks aren't dropped on all code paths. And don't even expect features of true database transactions like the ability to roll changes back in case of an error or guaranteed consistency after a system failure. True WTF masters don't just reinvent the wheel. They make it square, too.
It's funny, and yet it's sad, because it's all too common.
Don't bother, it boils down to "I hate everything I don't understand - be that frameworks, the abstract factory pattern or Euler's identity."
Back in 2000, I was contracted for GUI work on a Swing application. Java wasn't new to me and I had done some GUI work but mostly only with MFC (yuck!), yet I grokked Swing's MVC pattern in basically no time at all, and immediately appreciated the power of the approach in terms of performance. Am I that much smarter than that poster?
The only thing I disliked was the fact that the table view rendered the same control over and over instead of using one control for every field. That meant putting things like comboboxes inside a table was pretty much out of reach (you could hack by using a table editor, but this did not offer the expected look&feel). But that design decision was for performance, obviously. This led me to code up a solution (for MFC, err, because I had bought a Watcom IDE) to the problem which was a grid that only instantiated the controls that were currently visible through the associated scroll view. When the view area changed, a factory object would be called via an abstract interface that would produce the new controls. This worked really well although on afterthought the factory could've used a pool of reusable control instances for added performance. Of course other people had the same idea and there are some widget libraries that have (much more finessed) views which do basically the same thing.
The designers of Cocoa have found a nice middle ground between performance and generality by using so-called cell objects (one per column). These are lightweight GUI elements (more lightweight than views) that render themselves but unlike Swing table cells can also have custom behavior (without requiring the user to start a cell edit session by double-clicking).
The criticism fails on more grounds than just the author's inability to take a sit and RTFM. Any decent framework allows you to ignore it and re-invent the wheel if you must or just don't know how to use the pre-invented one. And any decent framework does not require you to know how all of this stuff works if all you want to do is write a Hello World application. A really good framework actually makes this tremendously easy by hiding all the ugliness of graphics modes, color depth, event dispatching and whatnot from you until you actually need to fiddle with low-level details like those. If the author wants to hate the remaining (and there are quite some) non-decent or outright bad frameworks, I'm all with him. Other than that, it's just another pointless rant.
Best. Comment. Ever!
Admin
This is I believe an instance of another anti-pattern: Fixing logical errors by ignoring them. The actual outcome is, of course, not that the program won't fail, but that it will fail in unpredictable rather than predictable ways. ON ERROR RESUME NEXT UNTIL EVERYTHING GOES ALL AWRY ANYHOW. Brillant!
PS to an anonymous poster: File locking on Windows is not broken. It's just a misnomer. It should be called "file name locking" because that's what it actually does, unfortunately. Inodes anyone?
Admin
The main problem I encounter with current locking, such as "built-in" (read available only compiled) transactions is that it doesn't expose its logic. In the generic locking scenario, I think of the fact that when a function is reading, any other function doing a read would be harmless, but a function doing a write would kill. With that in mind, a full lock could be done when a function is writing and a partial lock preventing only writes when a function is reading. However the current locking systems are from what I understand an all or nothing proposition. There's also the issue of understanding the locking mechanism and how the system prevents the lock from having the same contention issue as the object it is supposed to be protecting, stated as an oversimplification by "If the same exact function is started on different processors at the same exact time, which would get the lock snf hw would they know there was even a contention?"
Admin
It's a tough question - is the real wtf that he/they tried to do this, or that they did it so badly? Halfway through I was expecting to see a hacked together transaction-system based on client-side concurrency primitives such as synchronised objects or mutexes. Would that have been a smaller wtf or a bigger one?
Admin
lock level Paula = brillant!
On the topic: Maybe it's a good way in a sense that they can further extend this to be able to have the ability to lock several databases and probably even servers. That's what I'll call enterprisey...
Admin
To me, this just looks like a broken implementation of pessimistic locking. Sometimes DB transactions are insufficient (long-running transactions, XA transactions, etc.)
I suppose I should actually read the reasons for using pessimisting locking (optimistic locking is almost always a better choice... no need for 2am phone calls to use the unlocking tool) to see if it is the correct choice here, but these summaries are too damn long.
Admin
They just didn't take it far enough...they needed a LOCK_LOCK table to manage the locks that needed to performed on the first lock table. If they had done that, then the locking logic would have been logical.
Admin
You forgot:
Lock level -5 = Error: permission denied
Lock level -4 = Error: invalid syntax
Lock level -3 = Error: lock parameter incorrect
Lock level -2 = Error: lock does not exist
Lock level -1 = Error: unknown error
Inexplicably, no code has ever returned a negative value other than -1.
Admin
Now this is a ridiculous arrangement:
lock level 0 = unlocked
lock level 1 = exclusively locked
lock level 2 = cannot be locked
lock level 3 = superlock
lock level 4 = minilockAnybody experienced should know to make them 1,2,4,8,..and OR them together so you can have multiple states at once. And keep different sets of those constants in odd places so nobody's sure which applies.
Admin
In any case you need a tunnel or bridge for pedestrians to cross the line. An inner platform would incur the cost of only a branch of the tunnel or bridge.
Admin
Fictional? I saw one in my back garden the other day. The only come out late at night; they're attracted to the smell of alcohol on human breath, bizarrely.
Admin
My favorite is the "if locklevel <> '0' wait for ... 1 second". So if it's locked, we wait a second, and then lock it anyways... yeah. And s/he (the originator of this mud ball from hell) probably wonders why s/he wasn't on the dev team for the database. You forgot one other locklevel:
-999 me
Admin
lock level 0.5 = semilock