• ajk (unregistered) in reply to Volmarias

    Volmarias:
    Sweet jesus. If I was this guy's employer, I'd not only fire him, but sue him for the wages they paid him for deceiving the company into believing that he was competant. Then I'd fire whoever hired this guy, because they're clearly not competant at decision making

    well you are not "competant" speller.. that's for sure :)

  • sdrg (unregistered) in reply to ajk
    And on the Sixth Day did the Redundant God re-invent the Transaction.  And He saw that it was good.
    And thusly on the Seventh Day did the Redundant God rest, pleased with re-creating something just because.
  • Tei (unregistered) in reply to sdrg
    Anonymous:
    And on the Sixth Day did the Redundant God re-invent the Transaction.  And He saw that it was good.
    And thusly on the Seventh Day did the Redundant God rest, pleased with re-creating something just because.

    On the 3 day God inventented MySQL 3, thus his lack of transactions.

  • Petr Gladkikh (unregistered) in reply to Fruny

    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

  • Steffen Kruse (unregistered) in reply to mfarah

    lock level 8 = true

    lock level 9 = false

    lock level 10 = lock level 2 

  • anonymous (unregistered) in reply to Petr Gladkikh

    Anonymous:
    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

    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.

     

     

  • (cs) in reply to kuroshin
    kuroshin:

    Uh wait, I forgot the most important ones :

    lock level -1 : locklock [ A lock on an existing lock, smarty ]

    lock level -2 : recursivelock [ Surely, something enterprisey has to have recursion ]

    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

  • No One (unregistered) in reply to John Bigboote
    John Bigboote:
    Anonymous:
    kuroshin:
    lock level 0 = unlocked

    lock level 1 = exclusively locked 

    lock level 2 = cannot be locked

    lock level 3 = superlock

    lock level 4 = minilock

    lock level 5 = record file not found

    lock level 6 = headlock

    lock level 7 = cockb-lock
     



    lock level 8 = locked and loaded

    lock level 000089 = pad lock

    lock level 60 = LFG
  • (cs)
    jdieter:

    These WTF's are getting awfully wordy.

     

    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.

  • Cody (unregistered) in reply to No One
    Anonymous:
    John Bigboote:
    Anonymous:
    kuroshin:
    lock level 0 = unlocked

    lock level 1 = exclusively locked 

    lock level 2 = cannot be locked

    lock level 3 = superlock

    lock level 4 = minilock

    lock level 5 = record file not found

    lock level 6 = headlock

    lock level 7 = cockb-lock
     



    lock level 8 = locked and loaded

    lock level 000089 = pad lock

    lock level 60 = LFG

    lock level 9 = admin lock

    lock level 9 = not admin lock

    lock level 9 = Sunday

  • (cs)

    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?

     

  • Anon (unregistered) in reply to kuroshin
    kuroshin:
    lock level -1 : locklock
    Who's there?
  • Mike Johnson (unregistered) in reply to Tango Uniform

    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

  • (cs) in reply to kuroshin
    kuroshin:

    lock level 0 = unlocked

    lock level 1 = exclusively locked 

    lock level 2 = cannot be locked

    lock level 3 = superlock

    lock level 4 = minilock 

    To beat this topic to death some more, and I can't believe no one posted it yet:

    lock level 42 = lock The Universe

  • Anonymouser (unregistered) in reply to Cody
    Anonymous:
    Anonymous:
    John Bigboote:
    Anonymous:
    kuroshin:
    lock level 0 = unlocked

    lock level 1 = exclusively locked 

    lock level 2 = cannot be locked

    lock level 3 = superlock

    lock level 4 = minilock

    lock level 5 = record file not found

    lock level 6 = headlock

    lock level 7 = cockb-lock
     



    lock level 8 = locked and loaded

    lock level 000089 = pad lock

    lock level 60 = LFG

    lock level 9 = admin lock

    lock level 9 = not admin lock

    lock level 9 = Sunday

    lock level 12345: Hey, that's my luggage!

  • CynicalTyler (unregistered) in reply to John Bigboote
    John Bigboote:

    lock level -3: powerlock [A lock that cannot be broken using the admin utility, must be broken by a level 10 DBA with 18 dexterity. Roll for damage.]

    If only I wasn't using the original Dungeons and Admins system.  I hate calculating my TULC0 (to unlock lock class zero).
     

  • Rich (unregistered) in reply to anon
    Anonymous:
    Two lines, one platform,  one bridge:

    || P ^^
    || L ||
    || A BRIDGE -> Parking lot
    || T ||
    || F ||
    || O ||
    || R ||
    vv M ||

     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
     

     

  • jim (unregistered) in reply to Adam B.
    Anonymous:
    Oh, forgot that in that case they probably also should have implemented read-locks unless the data is always written after reading it.

    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.

  • Anon E Mouse (unregistered) in reply to Volmarias

    Volmarias:
    Sweet jesus. If I was this guy's employer, I'd not only fire him, but sue him for the wages they paid him for deceiving the company into believing that he was competant. Then I'd fire whoever hired this guy, because they're clearly not competant at decision making

    After that, I sure hope you'd quit, just to drive home the point. 

    </sarc>
  • Renan renan_s2 (unregistered)

    Can i CRY after having read this? If this was one of my employees I would punch him/her in the face.

  • Mike (unregistered) in reply to Tango Uniform
    Anonymous:

    Here is my question relating to database locks.

    1. User selects a record in a GUI list to edit
    2. System loads data into GUI edit window
    3. 30 minutes go by (while user is editing data in GUI, anyone else trying to edit it gets a message it is locked)
    4. User hits save button
    5. Record in database is updated

     Where would you need above described scenario?
     

  • (cs)

    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.

    pjsson:

    The following forum post on Joels is already a classic when it comes to describe how silly meta problem solving is, a must read: Why I Hate Frameworks

    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.

    John Bigboote:
    lock level -3: powerlock [A lock that cannot be broken using the admin utility, must be broken by a level 10 DBA with 18 dexterity. Roll for damage.]

    Best. Comment. Ever! 

  • (cs) in reply to notromda
    notromda:

    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?

    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?

  • (cs)

    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?"

  • csrster (unregistered) in reply to GettinSadda
    GettinSadda:

    OMG!

    One of the fundamental aspects of the implementation of any locking strategy is that the "discover the item is not currently locked - lock it ourselves" bit has to be atomic... otherwise two locks can get set at the same time!

    This was doomed to failure from the start (and as pointed out... pointless!!) 

     

    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?
     

  • (cs) in reply to Anonymouser
    Anonymous:
    Anonymous:
    Anonymous:
    John Bigboote:
    Anonymous:
    kuroshin:
    lock level 0 = unlocked

    lock level 1 = exclusively locked 

    lock level 2 = cannot be locked

    lock level 3 = superlock

    lock level 4 = minilock

    lock level 5 = record file not found

    lock level 6 = headlock

    lock level 7 = cockb-lock
     



    lock level 8 = locked and loaded

    lock level 000089 = pad lock

    lock level 60 = LFG

    lock level 9 = admin lock

    lock level 9 = not admin lock

    lock level 9 = Sunday

    lock level 12345: Hey, that's my luggage!

    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...



  • Bob (unregistered)

    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.

  • Mark (unregistered) in reply to Cody
    Anonymous:

    Colin McGuigan:
    The best part is that the locking logic itself is not transactional, so it's entirely possible for two or more processes to end up with the lock on a table.  Fun!

    That was fixed in the update.  Now the lock table is locked when locking a table.

     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.
     

  • James (unregistered) in reply to Fruny
    Anonymous:
    kuroshin:
    lock level 0 = unlocked

    lock level 1 = exclusively locked 

    lock level 2 = cannot be locked

    lock level 3 = superlock

    lock level 4 = minilock

    lock level 5 = record file not found

     

    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. 

     

  • supercynic (unregistered) in reply to kuroshin

     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 = minilock

     

    Anybody 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.

  • John Machin (unregistered)

    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.

  • ChrisH (unregistered)

    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.

  • (cs)

    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 

  • Bill (unregistered) in reply to Fruny

    lock level 0.5 = semilock

Leave a comment on “I Think I'll Call Them &quot;Transactions&quot;”

Log In or post as a guest

Replying to comment #:

« Return to Article