I Think I'll Call Them "Transactions"

« Return to Article
  • Bob Philhower 2006-10-31 13:29
    I&#39;d like to see a list of the 17 times that solving the &quot;meta-problem&quot; was useful.<br />
  • Glenn 2006-10-31 13:36
    <p>[quote user=&quot;Anonymous&quot;]I&#39;d like to see a list of the 17 times that solving the &quot;meta-problem&quot; was useful.<br />[/quote]</p><p>Unfortunately, they all occurred in 1959, and the wired patch panels were eventually recycled.&nbsp;</p>
  • Kluge Doctor 2006-10-31 13:41
    [quote user=&quot;Anonymous&quot;]<p>[quote user=&quot;Anonymous&quot;]I&#39;d like to see a list of the 17 times that solving the &quot;meta-problem&quot; was useful.<br />[/quote]</p><p>Unfortunately, they all occurred in 1959, and the wired patch panels were eventually recycled.&nbsp;</p><p>[/quote]</p><p>No, they are called technology break throughs, like going from&nbsp; VHS to DVD.<br /></p>
  • tanisha 2006-10-31 13:44
    [quote user=&quot;Alex Papadimoulis&quot;]<p><font size="-1">* I would have linked to the Wikipedia for these anti-patterns, but for some reason, there&#39;s no article on them. I assume everyone was just too busy contributing to the thirteen-page <strike>article</strike> dissertation on the <a href="http://en.wikipedia.org/wiki/Chocobo" target="_blank">Chocobo</a>,&nbsp;the fictional bird from the Final Fantasy video game series.</font></p><p>[/quote]</p><p>&nbsp;</p><p>Not only it holds&nbsp; <font size="-1">thirteen pages, it also exists in ten additional languages. <br /></font></p>
  • ewhac 2006-10-31 13:44
    <p>&quot;Hey!&nbsp; I remember this thing from my undergraduate week when we skimmed over Doug Comer&#39;s XINU book.&nbsp; I think they were called &#39;metaphores&#39;...&quot;</p><p>Bloody amateurs...</p>
  • eli 2006-10-31 13:46
    Inner-Platform Effect is also known (perhaps more correctly) as Second-System Effect: http://en.wikipedia.org/wiki/Second_system_syndrome<br />
  • kuroshin 2006-10-31 13:48
    [quote user=&quot;Alex Papadimoulis&quot;]<p>His transactional system was built on top of SQL Server 2000 and involved using a table called db__locks which had a row for each table in the database and contained the table&#39;s name and a lock level of 0 (not locked) or 1 (exclusively locked). Obviously, he had big expansion plans for the future.</p><p>[/quote]</p><p>Ok, smart Alec. You really killed the fun before they started on it.</p><p>lock level 0 = unlocked</p><p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock&nbsp;</p><p>[quote user=&quot;Alex Papadimoulis&quot;] <br /></p><p>Fun fact: this transactional system comes with an admin utility to reset the db__Locks table if needed. </p><p>Another fun fact: <strong>on-call developers</strong> use this utility fairly often in the middle of the night when they&#39;re woken up by a support call </p><p>[/quote]</p><p>Those on-call developers may be script readers. Over here, IT support staff are called engineers, mere programmers are called users, engineers are called consultants........</p><p>Reminds me of <em>Assenture</em> and their thousand strong team full of architects.</p><p>Anyway, Rob&#39;s predecessor may not have created that fun utility. That&#39;s usually the sign of someone continuing to use the virtual lock without understanding the WTF nature of it, or maybe management was Chocoboed into believing that the virtual lock was really useful.</p>
  • Anonymous Coward 2006-10-31 13:49
    Let's not forget WP's treatment of Anti-patterns in general.
    http://en.wikipedia.org/wiki/Anti-pattern
    There's an entire category of 61 logged anti-patterns, too. Should be good fodder to find SOMETHING to link to in the future.
    http://en.wikipedia.org/wiki/Category:Anti-patterns
  • Danack 2006-10-31 13:50
    &lt;I&gt;I would have linked to the Wikipedia for these anti-patterns, but for some reason, there&#39;s no article on them.&lt;/i&gt;<br /><br />Your Wikipedia search powers are weak, old man.<br /><br />http://en.wikipedia.org/wiki/Anti-pattern
  • HatTrick1914 2006-10-31 13:51
    [quote user=&quot;Anonymous&quot;] <p>&quot;Hey!&nbsp; I remember this thing from my undergraduate week when we skimmed over Doug Comer&#39;s XINU book.&nbsp; I think they were called &#39;metaphores&#39;...&quot;</p><p>Bloody amateurs...</p><p>[/quote]</p><p>Oh they may not be amateurs, I worked for a company that had an off the shelf quality monitoring system that did the exact same thing. It was developed by people that had 20+ years experience each. And if that wasn&#39;t bad enough they also had no clue what normalized data was, everything was stored in a flat table with humdreds of fields. After years of expansion they reached the limits of the number of fields you could have in a single table.</p>
  • Fruny 2006-10-31 13:51
    [quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p>lock level 5 = <strike>record</strike> file not found<br />
  • kuroshin 2006-10-31 13:52
    <p>[quote user=&quot;Anonymous&quot;]Inner-Platform Effect is also known (perhaps more correctly) as Second-System Effect: http://en.wikipedia.org/wiki/Second_system_syndrome<br />[/quote]</p><p>If I&#39;m not wrong, I&#39;m working on reversing that effect in one of our systems here.</p><p>Too bad, <a href="/forums/post/93761.aspx">I&#39;ve got to hide all the ugly stuff</a> instead of refactoring it or writing from scratch.<br /></p>
  • GettinSadda 2006-10-31 13:52
    <p>OMG!

    </p><p>One of the fundamental aspects of the implementation of any locking strategy is that the &quot;discover the item is not currently locked - lock it ourselves&quot; bit has to be <em>atomic</em>... otherwise two locks can get set at the same time!</p><p>This was doomed to failure from the start (and as pointed out... pointless!!)&nbsp;</p>
  • Volmarias 2006-10-31 13:53
    Sweet jesus. If I was this guy&#39;s employer, I&#39;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&#39;d fire whoever hired this guy, because they&#39;re clearly not competant at decision making
  • John Bigboote 2006-10-31 13:57
    [quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>lock level 6 = headlock</p><p>lock level 7 = cockb-lock<br />&nbsp;</p>
  • DontKnow 2006-10-31 14:01
    <p>Lovely race condition there.<br /></p><p>Next they have to implement message queues and events via database tables to further increase serialization.<br /></p>
  • sammybaby 2006-10-31 14:02
    <p>[quote user=&quot;Alex Papadimoulis&quot;]* I would have linked to the Wikipedia for these anti-patterns, but for some reason, there&#39;s no article on them. I assume everyone was just too busy contributing to the thirteen-page <strike>article</strike> dissertation on the <a href="http://en.wikipedia.org/wiki/Chocobo" target="_blank">Chocobo</a>,&nbsp;the fictional bird from the Final Fantasy video game series.[/quote]</p><p><br /><br />What? No love for the Chocobo? For shame, Alex.&nbsp;</p>
  • kuroshin 2006-10-31 14:02
    [quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>Uh wait, I forgot the most important ones :</p><p>lock level -1 : locklock [ A lock on an existing lock, smarty ]<br /></p>lock level -2 : recursivelock [ Surely, something enterprisey has to have recursion ]<br />
  • John Bigboote 2006-10-31 14:05
    [quote user=&quot;kuroshin&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>Uh wait, I forgot the most important ones :</p><p>lock level -1 : locklock [ A lock on an existing lock, smarty ]<br /></p><p>lock level -2 : recursivelock [ Surely, something enterprisey has to have recursion ]<br />[/quote]</p><p>&nbsp;</p><p>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.]<br /></p>
  • Colin McGuigan 2006-10-31 14:06
    The best part is that the locking logic itself is not transactional, so it&#39;s entirely possible for two or more processes to end up with the lock on a table.&nbsp; Fun!<br />
  • kuroshin 2006-10-31 14:08
    <p>[quote user=&quot;Colin McGuigan&quot;]The best part is that the locking logic itself is not transactional, so it&#39;s entirely possible for two or more processes to end up with the lock on a table.&nbsp; Fun!<br />[/quote]</p><p>You&#39;ve pointed out the uselessiness (like truthiness) of the admin utility. The locks are stored in a table that can be locked.<br /></p>
  • spacedman 2006-10-31 14:16
    <p>uncyclopedia.org has a more compact article on the <a href="http://uncyclopedia.org/wiki/Chocobo" title="chocobo">Chocobo</a></p><p>I wondered what &#39;Inner Platform Effect&#39; was. I imagined it was to to with railway stations. If you have two rail lines, you could either have two platforms on the outside of the line, or save money by having a single two-sided platform in the middle of the two lines. But then, ah, you need a tunnel or bridge to get to, which inflates the cost... The Inner Platform Effect. Its probably nothing to do with that...</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
  • Dazed 2006-10-31 14:19
    Anonymous:
    Inner-Platform Effect is also known (perhaps more correctly) as Second-System Effect: http://en.wikipedia.org/wiki/Second_system_syndrome<br />


    The Inner-Platform Effect appears to be a WIH [1]. It could very well be (often is?) one of the results of Second-System Syndrome, but AIUI they aren't the same thing.

    <p>[1] Was Invented Here.
  • rmg66 2006-10-31 14:23
    [quote user=&quot;Anonymous&quot;] <p>&quot;Hey!&nbsp; I remember this thing from my undergraduate week when we skimmed over Doug Comer&#39;s XINU book.&nbsp; I think they were called &#39;metaphores&#39;...&quot;</p><p>Bloody amateurs...</p><p>[/quote]</p><p>&nbsp;Semaphores???</p>
  • DigitalLogic 2006-10-31 14:25
    [quote user=&quot;kuroshin&quot;]<p>[quote user=&quot;Colin McGuigan&quot;]The best part is that the locking logic itself is not transactional, so it&#39;s entirely possible for two or more processes to end up with the lock on a table.&nbsp; Fun!<br />[/quote]</p><p>You&#39;ve pointed out the uselessiness (like truthiness) of the admin utility. The locks are stored in a table that can be locked.<br /></p>[/quote]<br /><br />You can lock the lock table using this locking scheme, but the only thing enforcing that lock is the application code. &nbsp;So the admin utility simply doesn&#39;t check to see if the lock table is locked before unlocking some other table.<br /><br />Try saying that three times fast.<br />
  • Cody 2006-10-31 14:30
    <p>[quote user=&quot;Colin McGuigan&quot;]The best part is that the locking logic itself is not transactional, so it&#39;s entirely possible for two or more processes to end up with the lock on a table.&nbsp; Fun!<br />[/quote]</p>That was fixed in the update.&nbsp; Now the lock table is locked when locking a table.<br />
  • rmg66 2006-10-31 14:31
    <p>I&#39;ve wrapped built-in functionality to suit my needs. But Completely re-invent it?</p><p>Imagine what it would look like if he wanted to get to the record-locking level?</p>
  • savar 2006-10-31 14:33
    <p>[quote user=&quot;Anonymous&quot;]Inner-Platform Effect is also known (perhaps more correctly) as Second-System Effect: http://en.wikipedia.org/wiki/Second_system_syndrome<br />[/quote]</p><p>&nbsp;That&#39;s not the same as inner-platform. I think there should be a wikipedia entry about inner-platform.</p>
  • pjsson 2006-10-31 14:34
    <p>[quote user=&quot;Alex Papadimoulis&quot;]...meta-problem: a problem with the process of creating a solution for the actual problem.[/quote]</p><p>The following forum post on Joels is already a classic when it comes to describe how silly meta problem solving is, a must read: <a href="http://discuss.joelonsoftware.com/default.asp?joel.3.219431.12" title="Why I Hate Frameworks" target="_blank">Why I Hate Frameworks</a><br /></p><h3 class="discuss"><br /></h3><p>&nbsp;</p><p>&nbsp;</p>
  • DigitalLogic 2006-10-31 14:38
    [quote user=&quot;GettinSadda&quot;]<p>OMG! </p><p>One of the fundamental aspects of the implementation of any locking strategy is that the &quot;discover the item is not currently locked - lock it ourselves&quot; bit has to be <em>atomic</em>... otherwise two locks can get set at the same time!</p><p>This was doomed to failure from the start (and as pointed out... pointless!!)&nbsp;</p>[/quote]<br /><br /><br /><br />&lt;sarcasm&gt;<br />That&#39;s an easy fix.<br /><br />[quote]<br />-- Wait for lock<br />SET TRANSACTION ISOLATION LEVEL SERIALIZABLE<br /><br />WHILE @LockLevel &lt;&gt; &#39;0&#39;<br /> BEGIN<br />&nbsp;&nbsp;&nbsp;&nbsp;BEGIN TRANSACTION<br /> &nbsp;&nbsp;&nbsp;&nbsp;SELECT @LockLevel = LockLevel<br /> &nbsp;&nbsp;&nbsp;&nbsp;FROM db__Locks<br /> &nbsp;&nbsp;&nbsp;&nbsp;WHERE LockTbl = &#39;GL_Operations&#39;<br /><br /> &nbsp;&nbsp;&nbsp;&nbsp;IF @LockLevel &lt;&gt; &#39;0&#39; ROLLBACK TRANSACTION<br /> END<br /><br />-- Set lock<br />UPDATE db__Locks<br /> SET LockLevel = &#39;1&#39;<br /> WHERE LockTbl = &#39;GL_Operations&#39;<br />COMMIT TRANSACTION<br /><br />... snip whole bunch of code ...<br /><br />-- Clear lock<br />UPDATE db__Locks<br /> SET LockLevel = &#39;0&#39;<br /> WHERE LockTbl = &#39;GL_Operations&#39;<br />[/quote]<br /><br />P.S - The real WTF is that he didn&#39;t put the locking logic in stored procedures. &nbsp;That would make adding the above fix much easier to implement.<br /><br />&lt;/sarcasm&gt;<br />
  • Tango Uniform 2006-10-31 14:38
    <p>Here is my question relating to database locks.</p><ol><li>User selects a record in a GUI list to edit<br /></li><li>System loads data into GUI edit window<br /></li><li>30 minutes go by (while user is editing data in GUI, anyone else trying to edit it gets a message it is locked)</li><li>User hits save button<br /></li><li>Record in database is updated</li></ol><p>What sort of &quot;locking&quot; mechanism would you use to implement this type of transaction, where a record has been read to be edited by a user, but this might take quite some time?&nbsp; How would having a limited pool of database connections impact such an implementation?&nbsp; How would the need to have a portable (between different databases) affect the implementation?</p><p>Basically, I have seen designs that have some sort of &quot;lock&quot; record on tables to indicate the record is in use by some user.&nbsp; This is not done necessarily to reimplement the concept of a transaction.&nbsp; In fact, these systems use a database transaction to test and update the lock field to ensure only one user gets the lock.&nbsp; It is more used for locking a record or set of records in order to allow a user to look at and edit the data, when a pessimistic lock is required.</p><p>In addition, how would one implement a portable optimistic locking scheme.&nbsp; Most of those I have seen involve having a &quot;last updated&quot; timestamp, where ensuring it hasn&#39;t changed is part of the update sql.</p><p>In essense, I have seen a lock flag field used for pessimistic locking, and a timestamp field used for optimistic locking, and have not seen any problems with these techniques.&nbsp; They seem to be versatile and portable, and don&#39;t require holding a database connection for long periods of time while the record is being edited on a GUI.<br /><br />Thanks.&nbsp;</p>
  • Reed 2006-10-31 14:50
    <p>http://c2.com/cgi/wiki?AntiPattern</p><p>http://c2.com/cgi/wiki?AntiPatternsCatalog</p><p>&nbsp;</p><p>The Inner Platform Effect:&nbsp; http://thedailywtf.com/forums/69415/ShowPost.aspx</p><p> &quot;The Inner-Platform Effect is a result of designing a system to be so
    customizable that it ends becoming a poor replica of the platform it
    was designed with.&quot;</p><p>&nbsp;</p><p>It&#39;s an over-engineering anti-pattern. Ostensibly it&#39;s designed to enable portability or ease future changes but generally ends up just sucking to work with.<br /></p><p>&nbsp;</p>
  • ParkinT 2006-10-31 15:00
    <p>After reading this story, all I have to say to <strong>Robert Rossney</strong> is:</p><p>&nbsp;</p><p>Good Lock !</p>
  • Hinek 2006-10-31 15:09
    <p>For those who don&#39;t know what the Inner-Platform Effect is:<br /></p><blockquote><p>The Inner-Platform Effect is a result of designing a system to be so
    customizable that it ends becoming a poor replica of the platform it
    was designed with. This &quot;customization&quot; of this dynamic inner-platform
    becomes so complicated that only a programmer (and not the end user) is
    able to modify it.</p></blockquote><p>http://thedailywtf.com/forums/69415/ShowPost.aspx</p>
  • Craig 2006-10-31 15:23
    <p>&quot;Now before all you database developers scream &quot;Use Built-in Transactions!,&quot; let me remind you that there are a whole lot of problems associated with built-in database transactions&quot;</p><p>But what about when built-in transactions are insufficient?</p><p>Sybase IQ supports transactions, but only allows one &#39;writer&#39; thread per table.&nbsp; This means that if you want to have multiple ways to update a single table you have to &#39;single-stream&#39; them.</p>
  • Milkshake 2006-10-31 15:26
    [quote user=&quot;rmg66&quot;][quote user=&quot;Anonymous&quot;] <p>&quot;Hey!&nbsp; I remember this thing from my undergraduate week when we skimmed over Doug Comer&#39;s XINU book.&nbsp; I think they were called &#39;metaphores&#39;...&quot;</p><p>Bloody amateurs...</p><p>[/quote]</p><p>&nbsp;Semaphores???</p><p>[/quote]</p><p>Give him a break.&nbsp; He only skimmed over the book, but&nbsp;obviously that&#39;s quite enough to&nbsp;justify him in calling someone else an amateur.</p>
  • Ghost Ware Wizard 2006-10-31 15:29
    <p>wtf?! sounds like the&nbsp;weed was smoked a little too much that day.</p><p>use a rdbms and then add layer upon layer of &quot;management&quot; constraints aka *slow* the system down.....</p><p>&nbsp;You Geek Code Something</p>
  • Grog 2006-10-31 15:39
    Why didn&#39;t he use a cursor to iterate over the list of locks? Come on, man!!!
  • Local guy 2006-10-31 15:40
    Nice to see some code :)
  • RetireBy40 2006-10-31 15:45
    <a href="http://en.wikipedia.org/wiki/Not_invented_here">http://en.wikipedia.org/wiki/Not_invented_here</a>
  • Rich 2006-10-31 15:50
    [quote user=&quot;Anonymous&quot;]<p>uncyclopedia.org has a more compact article on the <a href="http://uncyclopedia.org/wiki/Chocobo" title="chocobo">Chocobo</a></p><p>I wondered what &#39;Inner Platform Effect&#39; was. I imagined it was to to with railway stations. If you have two rail lines, you could either have two platforms on the outside of the line, or save money by having a single two-sided platform in the middle of the two lines. But then, ah, you need a tunnel or bridge to get to, which inflates the cost... The Inner Platform Effect. Its probably nothing to do with that...</p><p>&nbsp;</p><p>[/quote]


    </p><p>&nbsp;</p><p>WTF? If you have the platform between the lines, you need *two* bridges to be able to get anywhere (Unless the lines terminate (Waterloo Station, London) or you have level crossings where you walk across the track (Seen in Italy) which would be as applicable for the &quot;outer platforms&quot; anyway).</p><p>&nbsp;</p>
  • Alistair Wall 2006-10-31 15:59
    [quote user=&quot;Anonymous&quot;]<p>Here is my question relating to database locks.</p><ol><li>User selects a record in a GUI list to edit<br /></li><li>System loads data into GUI edit window<br /></li><li>30 minutes go by (while user is editing data in GUI, anyone else trying to edit it gets a message it is locked)</li><li>User hits save button<br /></li><li>Record in database is updated</li></ol><p>What sort of &quot;locking&quot; mechanism would you use to implement this type of transaction, where a record has been read to be edited by a user, but this might take quite some time?&nbsp; How would having a limited pool of database connections impact such an implementation?&nbsp; How would the need to have a portable (between different databases) affect the implementation?</p><p>Basically, I have seen designs that have some sort of &quot;lock&quot; record on tables to indicate the record is in use by some user.&nbsp; This is not done necessarily to reimplement the concept of a transaction.&nbsp; In fact, these systems use a database transaction to test and update the lock field to ensure only one user gets the lock.&nbsp; It is more used for locking a record or set of records in order to allow a user to look at and edit the data, when a pessimistic lock is required.</p><p>In addition, how would one implement a portable optimistic locking scheme.&nbsp; Most of those I have seen involve having a &quot;last updated&quot; timestamp, where ensuring it hasn&#39;t changed is part of the update sql.</p><p>In essense, I have seen a lock flag field used for pessimistic locking, and a timestamp field used for optimistic locking, and have not seen any problems with these techniques.&nbsp; They seem to be versatile and portable, and don&#39;t require holding a database connection for long periods of time while the record is being edited on a GUI.<br /><br />Thanks.&nbsp;</p><p>[/quote]</p><p>The mechanism varies by database, so you would put this in your database-specific layer. In Oracle you would select the system change number pseudo-column, then check the SCN again in the where clause of your update statement.&nbsp;</p><p>&nbsp;</p>
  • aliethel 2006-10-31 16:02
    I have to ask what does that say about me that I actually read the entire article and enjoyed it?<br />
  • anon 2006-10-31 16:02
    Two lines, one platform,&nbsp; one bridge:<br />
    <p>
    <tt>
    || P ^^<br />|| L ||<br />
    || A BRIDGE -&gt; Parking lot
    <br />|| T ||
    <br />|| F ||
    <br />|| O ||
    <br />|| R ||
    <br />vv M ||
    </tt>
    </p>
  • Ripper the Non-Believer 2006-10-31 16:24
    Next week:the non-blocking chocoblock.<br />
  • SwordfishBob 2006-10-31 16:32
    [quote user=&quot;Anonymous&quot;]Two lines, one platform,&nbsp; one bridge:[/quote]<br /><p><tt> || P ^^<br />|| L ||<br /> || A BRIDGE -&gt; Parking lot <br />|| T || <br />|| F || <br />|| O || <br />|| R || <br />vv M || </tt></p>Yeah, I recall seeing a&nbsp;few platforms as wobbly as variable-pitch-text-drawings, and with the end falling off..
  • iboB 2006-10-31 16:56
    [quote user=&quot;John Bigboote&quot;][quote user=&quot;kuroshin&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>Uh wait, I forgot the most important ones :</p><p>lock level -1 : locklock [ A lock on an existing lock, smarty ]<br /></p><p>lock level -2 : recursivelock [ Surely, something enterprisey has to have recursion ]<br />[/quote]</p><p>&nbsp;</p><p>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.]<br /></p><p>[/quote]

    </p><p>lock level 0xFFFFFFFF : division by zero</p>
  • Adam B. 2006-10-31 17:05
    [quote user=&quot;GettinSadda&quot;]<p>OMG!

    </p><p>One of the fundamental aspects of the implementation of any locking strategy is that the &quot;discover the item is not currently locked - lock it ourselves&quot; bit has to be <em>atomic</em>... otherwise two locks can get set at the same time!</p><p>This was doomed to failure from the start (and as pointed out... pointless!!)&nbsp;</p><p>[/quote]</p><p>&nbsp;</p><p>Actually, you can do it atomically with JDBC (probably ODBC and other mechanisms as well).&nbsp; Update lock_table set lock_value=1 where lock_value=0 and lock_name=&quot;whatever&quot;.&nbsp; If the return value is 1, you got the lock, otherwise no dice. There&#39;s even a legitimate (if exceedingly rare) use for this particular WTF. If it&#39;s a distributed system and the cost of cleaning up if you find out that the default optimistic working strategy is extremely high, this can be faster by reducing the number of times that you have to clean up.&nbsp; Of course, this also leads to loads of issues like having to do lock reclamation if a process hangs or dies, deadlock detection and who knows how many other issues. <br /></p>
  • Adam B. 2006-10-31 17:09
    Oh, forgot that in that case they probably also should have implemented read-locks unless the data is always written after reading it.<br />
  • xcor057 2006-10-31 17:11
    [quote user=&quot;kuroshin&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked <p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>Uh wait, I forgot the most important ones :</p><p>lock level -1 : locklock [ A lock on an existing lock, smarty ]<br /></p><p>lock level -2 : recursivelock [ Surely, something enterprisey has to have recursion ]<br />[/quote]</p><p>&nbsp;recursivelock - A lock that re-locks itself when unlocked?</p>
  • Wiki Refugee 2006-10-31 17:15

    <p>Funnily enough, I found TDWTF through a link from <strong>that very page</strong>.

    </p><p>&nbsp;</p><p>Captcha: <em>genius</em>. I quite agree.</p>
  • Wiki Refugee 2006-10-31 17:17
    <p>And, in the forums&#39; great wisdom, the post I was replying to was lost. I thought we didn&#39;t have these stupid bugs any more? Either way, the page I was referring to is http://en.wikipedia.org/wiki/Anti-pattern#External_links</p><p>&nbsp;</p><p>Captcha: catpcha&nbsp;</p>
  • triso 2006-10-31 17:20
    [quote user=&quot;Anonymous&quot;][quote user=&quot;Alex Papadimoulis&quot;]
    <p><font size="-1">* I would have linked to the Wikipedia for these anti-patterns, but for some reason, there&#39;s no article on them. I assume everyone was just too busy contributing to the thirteen-page <strike>article</strike> dissertation on the <a href="http://en.wikipedia.org/wiki/Chocobo" target="_blank">Chocobo</a>,&nbsp;the fictional bird from the Final Fantasy video game series.</font></p>

    <p>[/quote]</p>

    <p>&nbsp;</p>

    <p>Not only it holds&nbsp; <font size="-1">thirteen pages, it also exists in ten additional languages. <br />
    </font></p>
    [/quote]<font size="+1">D</font>amn!&nbsp; Nothing in Klingon yet.<br />
  • WWWWolf 2006-10-31 17:23
    <p>The most annoying part of this thing is that they can afford a Real Database System, and they elect to use it like Glorified MySQL 3.x. Clearly, a case of more money than sense.</p><p>And there&#39;s nice articles in WIkipedia on all these anti-patterns. <a href="http://en.wikipedia.org/wiki/Not_Invented_Here">Not Invented Here</a>, <a href="http://en.wikipedia.org/wiki/Stupidity">Invented Here, But Let&#39;s Reinvent It Anyway</a>, <a href="http://en.wikipedia.org/wiki/Second-system_effect">The Inner-Platform Effect</a> and <a href="http://en.wikipedia.org/wiki/Category:Anti-patterns">many others</a>... Say what you want about Wikipedians&#39; willingness to cover Boring Topics, but idiocies of computer science are not among the Boring Topics No One Bothers To Cover. =)<br /></p>
  • Disgruntled DBA 2006-10-31 17:27
    [quote user=&quot;John Bigboote&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>lock level 6 = headlock</p><p>lock level 7 = cockb-lock<br />&nbsp;</p><p>[/quote]</p><p>&nbsp;</p><p>lock level 8 = Matlock&nbsp;</p>
  • WWWWolf 2006-10-31 17:31
    <p>(On Chocobo article)<br /><br />[quote user=&quot;triso&quot;][quote]&nbsp;</p><p>Not only it holds&nbsp; <font size="-1">thirteen pages, it also exists in ten additional languages. <br />
    </font></p><p>
    [/quote]<font size="+1">D</font>amn!&nbsp; Nothing in Klingon yet.<br />[/quote]</p><p>Completely off-topic post to hopefully insert some rationality (?) and put a bit of a stop on further off-topic divergences:</p><ol><li>Klingon language, last I checked, didn&#39;t have word for Chocobos. Or, IIRC, birds in general.</li><li>Also, last I checked, Klingon Wikipedia was left permanently in read-only mode. There weren&#39;t enough contributors, or something like that.<br /></li></ol><p>&nbsp;</p>
  • Anonymous 2006-10-31 17:51
    <p>&quot;In essense, I have seen a lock flag field used for pessimistic locking,
    and a timestamp field used for optimistic locking, and have not seen
    any problems with these techniques.&nbsp; They seem to be versatile and
    portable, and don&#39;t require holding a database connection for long
    periods of time while the record is being edited on a GUI.&quot;</p><p>&nbsp;</p><p>You are not really &quot;locking&quot; the record.&nbsp; In fact, these schemes _rely_ on the internal atomic locking mechanisms to work.&nbsp; What you are really talking about is record _versioning_.&nbsp; Better to use a discrete integer to represent version changes rather than timestamp.&nbsp; However, you don&#39;t really need to do that either.&nbsp; Using predicated updates (updates that use the old values in the criteria) to verify it hasn&#39;t changed while updating it.&nbsp; <br /></p>
  • foxyshadis 2006-10-31 19:32
    [quote user=&quot;Anonymous&quot;][quote user=&quot;rmg66&quot;][quote user=&quot;Anonymous&quot;] <p>&quot;Hey!&nbsp; I remember this thing from my undergraduate week when we skimmed over Doug Comer&#39;s XINU book.&nbsp; I think they were called &#39;metaphores&#39;...&quot;</p><p>Bloody amateurs...</p><p>[/quote]</p><p>&nbsp;Semaphores???</p><p>[/quote]</p><p>Give him a break.&nbsp; He only skimmed over the book, but&nbsp;obviously that&#39;s quite enough to&nbsp;justify him in calling someone else an amateur.</p><p>[/quote]</p><p>Great job on totally missing the joke, both of you. Whoosh.</p><p>&nbsp;</p><p>And stop linking Second System for Inner Platform! They&#39;re totally different pathologies! Writing your own scripting language that translates your script to C++ and compiles, translating errors back into script, is an example of the latter (unless you&#39;re <font size="-1">Bjorne Stroustrup</font>), whereas rewriting it later to include all the features from every Perl and PHP module you can find (and accepting the syntaxes of several different languages) is the former.<br /></p>
  • tiller 2006-10-31 19:50
    <p>I think* the normal way to implement optimistic locking, is to include the original values in the where clause of the update. That way the update will not update any rows, if the rows have been changed since the client did read them. (Update returns the number of rows modified, so you can find out if this have happend, and then take action)<br /></p><p>&nbsp;<br />If you REALLY need pessimistic locking, but don&#39;t have any limit on how long the client can keep the lock, </p><p>just set the transaction to fail if it can&#39;t aquire the needed locks. That way the application can handle the problem, either by waiting for x seconds and the retrying, or by informing the user that the specified operation can&#39;t be done because someone else are using the database. <br /></p><p>&nbsp;</p><p>Atleast that the way I would do it. I don&#39;t hope this queto end up at http://www.dbdebunk.com :}<br /></p><p>&nbsp;</p><p>&nbsp;*(Not sure this is the normal way, but that is the way I would do it)&nbsp;</p><p>&nbsp;</p>
  • Ben 2006-10-31 20:07
    <p>This isn&#39;t in wiki because there&#39;s no reason to do this.&nbsp; I had the same feeling as a leading expert in the db arena Tom Kyte:&nbsp;</p><p>http://tkyte.blogspot.com/2006/10/this-site-owes-me-new-monitor.html</p>
  • mfarah 2006-10-31 20:49
    [quote user=&quot;John Bigboote&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>lock level 6 = headlock</p><p>lock level 7 = cockb-lock<br />&nbsp;</p><p>[/quote]

    </p><p>&nbsp;</p><p>lock level 0.001 = null lock<br /><br />lock level 0.000001 = very null lock
    </p>
  • thedoctor 2006-10-31 22:48
    <p>Actually this quite a common problem in web applications. </p><p>Timestamp is not safe because updates can be happening quite quickly (where batch processes are operating as well as user transactions). The most common solution is to add a version column to all tables and check this when doing an update. The hibernate documentation&nbsp;has&nbsp;a discussion about this issue.</p><p>&nbsp;</p><p>&nbsp;</p>
  • ajk 2006-10-31 23:49
    <p>[quote user=&quot;Volmarias&quot;]Sweet jesus. If I was this guy&#39;s employer, I&#39;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&#39;d fire whoever hired this guy, because they&#39;re clearly not competant at decision making[/quote]

    </p><p>well you are not &quot;competant&quot; speller.. that&#39;s for sure :)<br /> </p>
  • sdrg 2006-11-01 00:26
    <div>And on the Sixth Day did the Redundant God re-invent the Transaction.&nbsp; And He saw that it was good.</div><div></div><div>And thusly on the Seventh Day did the Redundant God rest, pleased with re-creating something just because.</div>
  • Tei 2006-11-01 02:43
    [quote user=&quot;Anonymous&quot;]<div>And on the Sixth Day did the Redundant God re-invent the Transaction.&nbsp; And He saw that it was good.</div><div></div><div>And thusly on the Seventh Day did the Redundant God rest, pleased with re-creating something just because.</div><p>[/quote]</p><p>On the 3 day God inventented MySQL 3, thus his lack of transactions.<br /></p>
  • seebs 2006-11-01 04:00
    <p>[quote user=&quot;Anonymous&quot;]Inner-Platform Effect is also known (perhaps more correctly) as Second-System Effect: http://en.wikipedia.org/wiki/Second_system_syndrome<br />[/quote]</p><p>No, these are unrelated.&nbsp; Second System syndrome was made famous by Brooks in MMM, and refers to the tendency of a second system to try to solve EVERYTHING that the first one didn&#39;t.&nbsp; Inner-Platform effect is the tendency of a system -- whether first, second, or thirty-ninth -- built on top of a platform, and trying to be very customizable, to replicate the base platform.&nbsp; (The example in the Daily WTF was a database built on top of... a database.)</p><p>&nbsp;If they were the same, System 360 would have run on top of earlier operating systems, and would have precisely emulated their feature set.&nbsp; Not the case.</p><p>&nbsp;(You could make a good case for vmunix.el being the inner-platform effect, though.)<br /><br />&nbsp;</p>
  • Petr Gladkikh 2006-11-01 04:48
    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 2006-11-01 04:59
    <p>lock level 8 = true</p><p>lock level 9 = false</p><p>lock level 10 = lock level 2&nbsp;</p>
  • anonymous 2006-11-01 07:04
    <p>[quote user=&quot;Anonymous&quot;]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[/quote]</p><p>Dont forget the way lock work on windows file systems!</p><p>&nbsp;<br />Level 1: Lock, you cant remove the file but you can write on it</p><p>Level 2: Everyone can write on it.<br /><br />&nbsp;</p><p>&nbsp;</p>
  • Alchymist 2006-11-01 07:50
    [quote user=&quot;kuroshin&quot;] <p>Uh wait, I forgot the most important ones :</p><p>lock level -1 : locklock [ A lock on an existing lock, smarty ]<br /></p><p>lock level -2 : recursivelock [ Surely, something enterprisey has to have recursion ]<br />[/quote]</p><p>Surely no need for a separate recursion setting, db__locks had a row for every table, presumably including itself.</p><p>I assume that&#39;s how they got round the race condition in the code snippet.&nbsp; We just weren&#39;t shown the surrounding code which locked db__locks</p>
  • No One 2006-11-01 08:43
    [quote user=&quot;John Bigboote&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>lock level 6 = headlock</p><p>lock level 7 = cockb-lock<br />&nbsp;</p>[/quote]<br /><br />lock level 8 = locked and loaded<br /><br />lock level 000089 = pad lock<br /><br />lock level 60 = LFG<br />
  • KenW 2006-11-01 09:11
    [quote user=&quot;jdieter&quot;]<p>These WTF&#39;s are getting awfully wordy. </p><p>&nbsp;[/quote]</p><p>Yeah... And some of the words have more than one syllable. ;-) I don&#39;t see a problem with the length of any of the posts.<br /></p>
  • Cody 2006-11-01 09:22
    [quote user=&quot;Anonymous&quot;][quote user=&quot;John Bigboote&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>lock level 6 = headlock</p><p>lock level 7 = cockb-lock<br />&nbsp;</p><p>[/quote]<br /><br />lock level 8 = locked and loaded<br /><br />lock level 000089 = pad lock<br /><br />lock level 60 = LFG<br />[/quote]

    </p><p>lock level 9 = admin lock</p><p>lock level 9 = not admin lock</p><p>lock level 9 = Sunday<br /></p>
  • notromda 2006-11-01 09:28
    <p>Reading through the anti patterns on wikipedia, I found a big WTF in the explanation of http://en.wikipedia.org/wiki/Sequential_Coupling</p><p>The author suggests that &quot;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.&quot;</p><p>So... a function should just return without doing anything or telling the user that it failed.&nbsp; I guess it&#39;s not important to tell the user that the transfer_money() function didn&#39;t work because they hadn&#39;t called authorize_transaction() first?<br /></p><p>&nbsp;</p>
  • Anon 2006-11-01 09:32
    [quote user=&quot;kuroshin&quot;]lock level -1 : locklock [/quote]Who&#39;s there?
  • Mike Johnson 2006-11-01 09:42
    I&#39;ve implemented a &quot;check out&quot; table before.. where a user checks out an item, and everyone else sees that it is checked out.&nbsp; You can &quot;un check out&quot; an item or have it expire based on a timestamp
  • jo42 2006-11-01 10:21
    [quote user=&quot;kuroshin&quot;] <p>lock level 0 = unlocked</p><p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock&nbsp;</p><p>[/quote]</p><p>To&nbsp;beat this topic to death some more, and I can&#39;t believe no one posted it yet:</p><p>lock level 42 = lock The Universe</p>
  • Anonymouser 2006-11-01 10:22
    [quote user=&quot;Anonymous&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;John Bigboote&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>lock level 6 = headlock</p><p>lock level 7 = cockb-lock<br />&nbsp;</p><p>[/quote]<br /><br />lock level 8 = locked and loaded<br /><br />lock level 000089 = pad lock<br /><br />lock level 60 = LFG<br />[/quote]

    </p><p>lock level 9 = admin lock</p><p>lock level 9 = not admin lock</p><p>lock level 9 = Sunday<br /></p>[/quote]

    lock level 12345: Hey, that&#39;s my luggage!
  • Ace_NoOne 2006-11-01 10:30
    <p>These kinda articles make me wish I was an actual coding geek instead of just a wannabe... (Read: I don&#39;t <span style="font-style: italic">really</span> understand, but I still laugh.)</p><p>&nbsp;</p><p>[quote user=&quot;Alex Papadimoulis&quot;]<font size="-1">I would have linked to the Wikipedia for these anti-patterns, but for some reason, there&#39;s no article on them.</font>[/quote]You know, the beauty (as well as the tragedy) of the wiki principle is that everyone can contribute - so if an article doesn&#39;t exist yet, you could just create it... (Captcha is &quot;bedtime&quot; - might be a clue for me to shuddup!?)<br /></p><p>[quote user=&quot;Alex Papadimoulis&quot;]<font size="-1">I assume everyone was just too busy contributing to the thirteen-page <strike>article</strike> dissertation on the <a href="http://en.wikipedia.org/wiki/Chocobo" target="_blank">Chocobo</a>,&nbsp;the fictional bird from the Final Fantasy video game series.</font>[/quote]Gotta love those kinda comments - simply brilliant!<br /></p>
  • CynicalTyler 2006-11-01 10:54
    [quote user=&quot;John Bigboote&quot;]<p>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.]<br /></p><p>[/quote]</p><p>If only I wasn&#39;t using the original Dungeons and Admins system.&nbsp; I hate calculating my TULC0 (to unlock lock class zero).<br />&nbsp;</p>
  • rycamor 2006-11-01 11:19
    <p>Speaking of antipatterns, it&#39;s high time there was a Wikipedia entry on &quot;Database antipatterns&quot; as distinct from general software antipatterns.</p><p>My personal favorite would be the <a href="http://www.dbazine.com/ofinterest/oi-articles/celko22" title="One True Lookup Table">One True Lookup Table</a> (also see http://tonyandrews.blogspot.com/2004/10/otlt-and-eav-two-big-design-mistakes.html)</p><p><a href="http://tkyte.blogspot.com/2006/10/this-site-owes-me-new-monitor.html">Tom Kyte</a> talks about a few more in the link above. (cool, TDWTF got a link from TKyte!)<br /></p><p>Another one I&#39;ve seen many times is the classic misunderstanding of &quot;de-normalize for performance&quot;, resulting in a giant table containing every possible attribute of the application, with of course every column except the primary key nullable.</p><p>And, of course, the inevitable developer you run into at every company who uses loops in the application layer rather than spending 10 minutes to understand LEFT OUTER JOIN, or any join at all, for that matter.<br /><br /><br />&nbsp;</p>
  • Rich 2006-11-01 14:16
    [quote user=&quot;Anonymous&quot;]Two lines, one platform,&nbsp; one bridge:<br />
    <p>
    <tt>
    || P ^^<br />|| L ||<br />
    || A BRIDGE -&gt; Parking lot
    <br />|| T ||
    <br />|| F ||
    <br />|| O ||
    <br />|| R ||
    <br />vv M ||
    </tt>
    </p><p>[/quote]</p><p>&nbsp;True. Though I was thinking that you might need to get over the other side of the railway lines somehow (assuming that you haven&#39;t built your railway along the sea). In your diagram that requires some kind of additional crossing.</p><p>That said, with the &quot;outer platform&quot; 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).</p><p>When is today&#39;s WTF coming out anyway?</p><p>&nbsp;Rich<br />&nbsp;</p><p>&nbsp;</p>
  • jim 2006-11-01 14:44
    Anonymous:
    Oh, forgot that in that case they probably also should have implemented read-locks unless the data is always written after reading it.<br />


    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.
  • Harry 2006-11-01 14:55
    [quote user=&quot;Anonymous&quot;][quote user=&quot;Anonymous&quot;]<p>uncyclopedia.org has a more compact article on the <a href="http://uncyclopedia.org/wiki/Chocobo" title="chocobo">Chocobo</a></p><p>I wondered what &#39;Inner Platform Effect&#39; was. I imagined it was to to with railway stations. If you have two rail lines, you could either have two platforms on the outside of the line, or save money by having a single two-sided platform in the middle of the two lines. But then, ah, you need a tunnel or bridge to get to, which inflates the cost... The Inner Platform Effect. Its probably nothing to do with that...</p><p>&nbsp;</p><p>[/quote]


    </p><p>&nbsp;</p><p>WTF? If you have the platform between the lines, you need *two* bridges to be able to get anywhere (Unless the lines terminate (Waterloo Station, London) or you have level crossings where you walk across the track (Seen in Italy) which would be as applicable for the &quot;outer platforms&quot; anyway).</p><p>&nbsp;</p><p>[/quote]</p><p>&nbsp;</p><p>Clearly the correct answer is to merge the rail lines and make access to the platform transactional.</p><p>&nbsp;</p><p>&nbsp;</p>
  • Anon E Mouse 2006-11-01 15:07
    <p>[quote user=&quot;Volmarias&quot;]Sweet jesus. If I was this guy&#39;s employer, I&#39;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&#39;d fire whoever hired this guy, because they&#39;re clearly not competant at decision making[/quote]</p><p>After that, I sure hope you&#39;d quit, just to drive home the point.&nbsp;</p>&lt;/sarc&gt;
  • Renan renan_s2 2006-11-01 16:19
    Can i CRY after having read this? If this was one of my employees I would punch him/her in the face.<br />
  • Mike 2006-11-01 16:20
    [quote user=&quot;Anonymous&quot;]<p>Here is my question relating to database locks.</p><ol><li>User selects a record in a GUI list to edit<br /></li><li>System loads data into GUI edit window<br /></li><li>30 minutes go by (while user is editing data in GUI, anyone else trying to edit it gets a message it is locked)</li><li>User hits save button<br /></li><li>Record in database is updated</li></ol><p>[/quote]</p><p>&nbsp;Where would you need above described scenario?<br />&nbsp;</p>
  • For Great Justice 2006-11-01 16:33
    Maybe some manager forced him to do it... Later on, he became this guy: <a href="http://disgruntster.wordpress.com/" title="Disgruntled Employee">http://disgruntster.wordpress.com/</a><br />
  • Alexis de Torquemada 2006-11-01 19:14
    <p>This code just has it all. Semi-active waiting, race conditions (as has been mentioned) and deadlocks too because SPs can&#39;t agree on the order in which they acquire locks and/or some locks aren&#39;t dropped on all code paths. And don&#39;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&#39;t just reinvent the wheel. They make it square, too.&nbsp;</p><p>It&#39;s funny, and yet it&#39;s sad, because it&#39;s all too common.</p><p>[quote user=&quot;pjsson&quot;]<br />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<br />[/quote]</p><p>Don&#39;t bother, it boils down to &quot;I hate everything I don&#39;t understand - be that frameworks, the abstract factory pattern or <a href="http://en.wikipedia.org/wiki/Euler%27s_Identity">Euler&#39;s identity</a>.&quot;</p><p>Back in 2000, I was contracted for GUI work on a Swing application. Java wasn&#39;t new to me and I had done some GUI work but mostly only with MFC (yuck!), yet I grokked Swing&#39;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?</p><p>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&amp;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&#39;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.</p><p>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).<br /></p><p>The criticism fails on more grounds than just the author&#39;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&#39;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&#39;m all with him. Other than that, it&#39;s just another pointless rant.<br /><br /></p><p>[quote user=&quot;John Bigboote&quot;]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.]<br />[/quote]</p><p>Best. Comment. Ever!&nbsp;</p>
  • Alexis de Torquemada 2006-11-01 19:33
    [quote user=&quot;notromda&quot;]<p>So... a function should just return without doing anything or telling the user that it failed.&nbsp; I guess it&#39;s not important to tell the user that the transfer_money() function didn&#39;t work because they hadn&#39;t called authorize_transaction() first?<br />[/quote]</p><p>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&#39;t fail, but that it will fail in unpredictable rather than predictable ways. ON ERROR RESUME NEXT UNTIL EVERYTHING GOES ALL AWRY ANYHOW. Brillant!</p><p>PS to an anonymous poster: File locking on Windows is not broken. It&#39;s just a misnomer. It should be called &quot;file name locking&quot; because that&#39;s what it actually does, unfortunately. Inodes anyone?<br /></p>
  • hackwrench 2006-11-01 20:47
    The main problem I encounter with current locking, such as &quot;built-in&quot; (read available only compiled) transactions is that it doesn&#39;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&#39;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 &nbsp;&quot;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?&quot;
  • csrster 2006-11-02 02:49
    [quote user=&quot;GettinSadda&quot;]<p>OMG!

    </p><p>One of the fundamental aspects of the implementation of any locking strategy is that the &quot;discover the item is not currently locked - lock it ourselves&quot; bit has to be <em>atomic</em>... otherwise two locks can get set at the same time!</p><p>This was doomed to failure from the start (and as pointed out... pointless!!)&nbsp;</p><p>[/quote]</p><p>&nbsp;</p><p>It&#39;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?<br />&nbsp;</p>
  • xrT 2006-11-02 04:15
    [quote user=&quot;Anonymous&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;John Bigboote&quot;][quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked <p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>lock level 6 = headlock</p><p>lock level 7 = cockb-lock<br />&nbsp;</p><p>[/quote]<br /><br />lock level 8 = locked and loaded<br /><br />lock level 000089 = pad lock<br /><br />lock level 60 = LFG<br />[/quote] </p><p>lock level 9 = admin lock</p><p>lock level 9 = not admin lock</p><p>lock level 9 = Sunday<br /></p>[/quote] lock level 12345: Hey, that&#39;s my luggage![/quote]<br />lock level Paula = brillant!<br /><br />On the topic: Maybe it&#39;s a good way in&nbsp;a sense that they can further extend this to be able to have the ability to lock several databases and probably even servers. That&#39;s what I&#39;ll call enterprisey...<br /><br /><br /><br />
  • Bob 2006-11-02 10:37
    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 2006-11-02 17:07
    [quote user=&quot;Anonymous&quot;]<p>[quote user=&quot;Colin McGuigan&quot;]The best part is that the locking logic itself is not transactional, so it&#39;s entirely possible for two or more processes to end up with the lock on a table.&nbsp; Fun!<br />[/quote]</p><p>That was fixed in the update.&nbsp; Now the lock table is locked when locking a table.<br />[/quote]</p><p>&nbsp;They just didn&#39;t take it far enough...they needed a LOCK_LOCK table to manage the locks that needed to performed on the first lock table.&nbsp; If they had done that, then the locking logic would have been logical.<br />&nbsp;</p>
  • James 2006-11-02 17:54
    [quote user=&quot;Anonymous&quot;][quote user=&quot;kuroshin&quot;]lock level 0 = unlocked<p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p><p>lock level 4 = minilock <br />[/quote]</p><p>lock level 5 = <strike>record</strike> file not found<br />[/quote]</p><p>&nbsp;</p><p>You forgot:</p><p>Lock level -5 = Error: permission denied&nbsp;</p><p>Lock level -4 = Error: invalid syntax&nbsp;</p><p>Lock level -3 = Error: lock parameter incorrect<br /></p><p>Lock level -2 = Error: lock does not exist<br /> </p><p>Lock level -1 = Error: unknown error</p><p>&nbsp;</p><p>&nbsp;</p><p>Inexplicably, no code has ever returned a negative value other than -1.&nbsp;</p><p>&nbsp;</p>
  • supercynic 2006-11-02 17:54
    <p>&nbsp;Now this is a ridiculous arrangement:<br /></p><p>&nbsp;</p><p>lock level 0 = unlocked</p><p>lock level 1 = exclusively locked&nbsp;</p><p>lock level 2 = cannot be locked</p><p>lock level 3 = superlock</p>lock level 4 = minilock<p>&nbsp;</p><p>Anybody experienced should know to make them&nbsp; 1,2,4,8,..and OR them together so you can have multiple states at once.&nbsp; And keep different sets of those constants in odd places so nobody&#39;s sure which applies.<br /></p>
  • John Machin 2006-11-02 21:00
    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.<br />
  • ChrisH 2006-11-06 06:03
    Fictional?&nbsp; I saw one in my back garden the other day.&nbsp; The only come out late at night; they&#39;re attracted to the smell of alcohol on human breath, bizarrely.<br />
  • sir_flexalot 2006-11-20 08:23
    <p>My favorite is the &quot;if locklevel &lt;&gt; &#39;0&#39; wait for ... 1 second&quot;.&nbsp; So if it&#39;s locked, we wait a second, and then lock it anyways... yeah.&nbsp; And s/he (the originator of this mud ball from hell) probably wonders why s/he wasn&#39;t on the dev team for the database.&nbsp; You forgot one other locklevel:</p><p>-999 me&nbsp;</p>
  • Bill 2007-04-20 21:02
    lock level 0.5 = semilock