I just discovered this.  I have a huge database... close to 46 gig to be exact.  Can you provide some help with this.  Thanks<br><br><div class="gmail_quote">On Fri, Jan 8, 2010 at 8:55 AM, Michael Friedrich <span dir="ltr"><<a href="mailto:michael.friedrich@univie.ac.at">michael.friedrich@univie.ac.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
any updates on that? Or no more complaints about duplicate rows?<br>
<br>
Depending on demand I could provide the fixed version from Icinga<br>
IDOUtils (and also a clean upgrading path without data loss) for<br>
NDOUtils usage...<br>
<br>
Kind regards,<br>
Michael<br>
<div><div></div><div class="h5"><br>
Hendrik Baecker wrote:<br>
> -----BEGIN PGP SIGNED MESSAGE-----<br>
> Hash: SHA1<br>
><br>
> Hi List,<br>
><br>
> a few days ago Øyvind Nordang, Julien Mathis and  Michael Friedrich,<br>
> discussed about duplicate rows in the servicecheck table.<br>
> Michael dropped me a few lines off-list showing up the problem exists<br>
> in some more tables.<br>
><br>
> The underlying problem:<br>
> MySQL queries like<br>
>     "insert into... on duplicate key update..."<br>
> needs primary and/or unique keys to be hit by the query to trigger the<br>
> UPDATE instead of the INSERT.<br>
> Most of the relevant keys for those queries are actually primary nor<br>
> unique keys, they are just KEYs.<br>
><br>
> So we have(98%) / might have (2%) duplicate entries in the following<br>
> tables:<br>
><br>
> nagios_servicechecks<br>
> nagios_systemcommands<br>
> nagios_timedeventqueue<br>
> nagios_timedevents<br>
><br>
> Now to the problem from the point of development: I see no good<br>
> solution to handle this.<br>
><br>
> One part of the solution is to change the keys to define the mandatory<br>
> UNIQUE keys, but this can't be done cleanly on existing data since you<br>
> can't define some UNIQUE keys on rows that would be duplicates.<br>
><br>
> Solutions to be discussed:<br>
><br>
> 1. Big-Bang-Solution<br>
> Define the user have to truncate above tables to be able to set the<br>
> right keys.<br>
> This will result in data loss.<br>
><br>
> 2.<br>
> It might be possible to write some nifty upgrade scripts to dump the<br>
> data out of the database, set the unique keys and try to re-import the<br>
> data with some fault tolerance.<br>
> Anyone out there with some experience on this level?<br>
> Contra:<br>
> Depending on the amount of data, such a job might be: a long runner<br>
> (time); complicated; not realy error resistant...<br>
><br>
> What thinks this community about the cost-benefit ratio?<br>
><br>
> IMO:<br>
> nagios_timedevent* table are not so important and data loss is irrelevant.<br>
> nagios_systemcommands might be just more interesting for someone<br>
> but nagios_servicechecks seems to me like a treasure of gold, data<br>
> loss in here might be realy painful<br>
><br>
> Any comments?<br>
> May be someone is able to adress some voodoo data repair query/script<br>
> to eliminate those duplicates before key changing?<br>
><br>
> - -<br>
> Hendrik<br>
><br>
> PS<br>
> For the interested one, the following key changes should be done:<br>
><br>
> ALTER table nagios_servicechecks DROP key instance_id;<br>
> ALTER table nagios_servicechecks DROP key service_object_id;<br>
> ALTER table nagios_servicechecks DROP key start_time;<br>
> ALTER table nagios_servicechecks DROP key start_time_usec;<br>
> ALTER table nagios_servicechecks ADD UNIQUE KEY `instance_id`<br>
> (`instance_id`,`service_object_id`,`start_time`,`start_time_usec`);<br>
><br>
><br>
> ALTER table nagios_systemcommands DROP KEY instance_id;<br>
> ALTER table nagios_systemcommands DROP KEY start_time;<br>
> ALTER table nagios_systemcommands DROP KEY start_time_usec;<br>
> ALTER table nagios_systemcommands ADD UNIQUE KEY `instance_id`<br>
> (`instance_id`,`start_time`,`start_time_usec`);<br>
><br>
><br>
> ALTER table nagios_timedeventqueue DROP KEY instance_id;<br>
> ALTER table nagios_timedeventqueue DROP KEY event_type;<br>
> ALTER table nagios_timedeventqueue DROP KEY scheduled_time;<br>
> ALTER table nagios_timedeventqueue DROP KEY object_id;<br>
> ALTER table nagios_timedeventqueue ADD UNIQUE KEY `instance_id`<br>
> (`instance_id`,`event_type`,`scheduled_time`, `object_id`);<br>
><br>
><br>
> ALTER table nagios_timedevents DROP KEY instance_id;<br>
> ALTER table nagios_timedevents DROP KEY event_type;<br>
> ALTER table nagios_timedevents DROP KEY scheduled_time;<br>
> ALTER table nagios_timedevents DROP KEY object_id;<br>
> ALTER table nagios_timedevents ADD UNIQUE KEY `instance_id`<br>
> (`instance_id`,`event_type`,`scheduled_time`,`object_id`);<br>
><br>
><br>
> -----BEGIN PGP SIGNATURE-----<br>
> Version: GnuPG v1.4.7 (MingW32)<br>
><br>
> iD8DBQFLAXLOlI0PwfxLQjkRAhn5AJ9ouNnmO4PwLzFv0y6AjGhdZP3gdgCggPo1<br>
> fXVPEgT2d3UeEg3HNrsdKac=<br>
> =fJuZ<br>
> -----END PGP SIGNATURE-----<br>
><br>
><br>
> ------------------------------------------------------------------------------<br>
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day<br>
> trial. Simplify your report design, integration and deployment - and focus on<br>
> what you do best, core application coding. Discover what's new with<br>
> Crystal Reports now.  <a href="http://p.sf.net/sfu/bobj-july" target="_blank">http://p.sf.net/sfu/bobj-july</a><br>
> _______________________________________________<br>
> Nagios-devel mailing list<br>
> <a href="mailto:Nagios-devel@lists.sourceforge.net">Nagios-devel@lists.sourceforge.net</a><br>
> <a href="https://lists.sourceforge.net/lists/listinfo/nagios-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-devel</a><br>
><br>
<br>
<br>
</div></div>------------------------------------------------------------------------------<br>
This SF.Net email is sponsored by the Verizon Developer Community<br>
Take advantage of Verizon's best-in-class app development support<br>
A streamlined, 14 day to market process makes app distribution fast and easy<br>
Join now and get one step closer to millions of Verizon customers<br>
<a href="http://p.sf.net/sfu/verizon-dev2dev" target="_blank">http://p.sf.net/sfu/verizon-dev2dev</a><br>
<div><div></div><div class="h5">_______________________________________________<br>
Nagios-devel mailing list<br>
<a href="mailto:Nagios-devel@lists.sourceforge.net">Nagios-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nagios-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/nagios-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Cordially,<br>Shadhin Rahman<br>