List:General Discussion« Previous MessageNext Message »
From:Yves Goergen Date:November 13 2007 8:29pm
Subject:Re: Transactions and locking
View as plain text  
On 13.11.2007 20:57 CE(S)T, Baron Schwartz wrote:
> It will absolutely lock SELECTs.  Are you sure autocommit is set to 0 
> and you have an open transaction?  Are you sure your table is InnoDB? 
> I'm doing this right now:
> 
> -- cxn 1
> mysql> set autocommit=0;
> mysql> begin;
> mysql> select * from t1 for update;
> +------+
> | a    |
> +------+
> |    1 |
> +------+
> 1 row in set (0.00 sec)
> 
> -- cxn 2
> mysql> set autocommit=0;
> mysql> begin;
> mysql> select * from t1 for update;

Okay, my fault, I didn't use the "FOR UPDATE" in the second connection.
If I do (which is likely to be the case in an application because there,
the same code is run concurrently), the second SELECT locks. (The same
is true when I select MAX(id) instead of *.) If I don't, it still works.
Okay, so we have some table locking, tested, working. Very nice. Thank
you for this one. :)

> ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

-- 
Yves Goergen "LonelyPixel" <nospam.list@stripped>
Visit my web laboratory at http://beta.unclassified.de
Thread
Transactions and lockingYves Goergen12 Nov
  • Re: Transactions and lockingMartijn Tonies12 Nov
  • Re: Transactions and lockingPerrin Harkins12 Nov
    • Re: Transactions and lockingYves Goergen12 Nov
      • Re: Transactions and lockingPerrin Harkins12 Nov
      • Re: Transactions and lockingYves Goergen12 Nov
        • Re: Transactions and lockingYves Goergen12 Nov
          • Re: Transactions and lockingPerrin Harkins12 Nov
            • Re: Transactions and lockingYves Goergen12 Nov
              • Re: Transactions and lockingPerrin Harkins13 Nov
                • Re: Transactions and lockingYves Goergen13 Nov
                  • mysqlhotcopyMalka Cymbalista13 Nov
                  • Re: Transactions and lockingBaron Schwartz13 Nov
                    • Re: Transactions and lockingmark addison13 Nov
                      • Re: Transactions and lockingYves Goergen13 Nov
                        • Re: Transactions and lockingBaron Schwartz13 Nov
                          • Re: Transactions and lockingYves Goergen13 Nov
                            • Re: Transactions and lockingBaron Schwartz13 Nov
                          • Re: Transactions and lockingPerrin Harkins13 Nov
                            • Re: Transactions and lockingYves Goergen13 Nov
                              • Re: Transactions and lockingBaron Schwartz13 Nov
                                • Re: Transactions and lockingYves Goergen13 Nov
                    • Re: Transactions and lockingYves Goergen13 Nov
                    • Re: Transactions and lockingYves Goergen13 Nov
                      • Re: Transactions and lockingBaron Schwartz13 Nov
                        • Re: Transactions and lockingYves Goergen13 Nov
                        • Re: Transactions and lockingYves Goergen13 Nov
                          • Re: Transactions and lockingPerrin Harkins13 Nov
  • Re: Transactions and lockingMartijn Tonies13 Nov
  • Re: Transactions and lockingMartijn Tonies14 Nov
    • Re: Transactions and lockingYves Goergen15 Nov
  • Re: Transactions and lockingMartijn Tonies15 Nov
Re: Transactions and lockingYves Goergen13 Nov
  • Re: Transactions and lockingPerrin Harkins13 Nov