Brice Figureau wrote:
>> I believe MySQL with the MyISAM backend doesn't actually enforce uniqueness,
>> but MyISAM is so utterly broken that we ought not to support that at all.
>> Are there any other "databases" that doesn't enforce constraints?
> That's wrong, MyISAM supports uniqueness constraints. What MyISAM
> doesn't support is transactions and foreign keys. I would not advice
> running MyISAM in production.
I would not advice running MyISAM in *any* kind of environment. :-)
And I'm fairly certain that it doesn't support normal constraints (i.e.
enforcing that columns have certain values), so I thought it didn't
handle uniqueness constraints either. But then I misremembered.
>> (Note though that I don't know how the database schema we use look like,
>> so I don't know how painful it would be to add such indexes to the
>> current schema.)
>
> It is not painful: it is impossible for the reason I already gave in the
> other branch of this thread.
>
> Basically fact names, tag names, or parameter names can't be unique in a
> transaction system, because transaction are run in isolation.
> Adding uniqueness constraint to those tables will only create failing
> transactions if two transactions try to add the same fact names.
Then the application should retry the transaction. In this case it seems
likely that you should try an UPDATE first, and if that fails due to no
matching record to update, do an INSERT. And if *that* fails due to
uniqueness breaking, retry the UPDATE again (because another client had
managed to get its transaction in between our tries). This is on the
assumption that the case where the record already exists and just needs
updating is the most common case. If that's not the case, you should
switch the order around.
This is standard procedure in *any* database application that pretends to
be even a little bit robust. You need that kind of logic anyway to handle
various other database errors. Yes, it is lot of work writing robust
programs; get used to it.
(I'm however not volunteering to write that code in Puppet. We don't
use storedconfigs, and I hope to keep it that way, so I can't justify
spending that time.)
/Bellman
--
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.