On Wed, 2009-12-02 at 16:22 +0800, Ohad Levy wrote:
> 
> On Wed, Dec 2, 2009 at 4:03 PM, Brice Figureau
> <[email protected]> wrote:
>         
>         
>         This renormalizes a mysql storeconfigs database.
>         It can happen that for (various, some still unexplained)
>         reasons a long
>         running mysql storeconfigs database contains duplicated
>         resources,
>         duplicated tags, duplicated parameter names.
>         This script aims to remove all duplications of such entities.
> Are we not using the rails validation methods on purpose ?
> e.g. 
> validate_uniqueness_of :name 
> will ensure that no two (hosts, parameters etc) will be created.

No we don't. (I'm not rails expert and wasn't even aware of this).

> This ofcourse generates another select statement each time (to verify
> if it already exists)...

The problem is that it won't work.
Look to what I wrote on the problem back in last March when I
contributed the dbfix thing:

On Tue, 2009-03-17 at 11:35 +0100, Brice Figureau wrote:
> Most (if not all) RDBMS run in REPEATABLE READ isolation mode, which
> means the selects they are doing while in a transaction return the
> data as it was before the transaction started.
> 
> Hence the following scenario, involving the following two clients A
> and
> B:
> 
> 1. fresh start, nothing in fact_names table
> 2. A: starts transaction
> 3. A: reads fact_names, oh, there is nothing
> 4. A: inserts one fact_names (say ipaddress)
> 5. B: starts transaction
> 6. B: reads fact_names, it won't read what A stored since A's
> transaction still isn't committed
> 7. A: commit, fact_names contains "ipaddress" from A
> 8. B: inserts the ipadress fact_names
> 9. B: commits
> 10. table fact_names contains 2 identical records.
> 
> The only way to have a unique record is to run your RDBMS in
> SERIALIZED
> mode, which is a real killer for concurrency (hence why vendors ships
> with REPEATABLE READs by default).


-- 
Brice Figureau
Follow the latest Puppet Community evolutions on www.planetpuppet.org!

--

You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to