Quantcast
Channel: StackExchange Replication Questions
Viewing all articles
Browse latest Browse all 17268

The primary key issue with slave

$
0
0

The slave is not working due to primary key error as shown below:

      Last_SQL_Errno: 1062
       Last_SQL_Error: Error 'Duplicate entry '550696860' for key 'PRIMARY'' on query.
 Default database: 'vserv'. 
 Query: 
  'INSERT INTO ox_data_intermediate_ad
        (date_time, ad_id, zone_id, clicks, impressions, 
         requests, operation_interval, operation_interval_id, 
         interval_start, interval_end, creative_id, updated)
    SELECT
        date_time, ad_id, zone_id, SUM(clicks) AS clicks, 
        SUM(impressions) AS impressions, SUM(requests) AS requests, 
        5 AS operation_interval, 1871 AS operation_interval_id, 
        '2012-05-26 11:55:00' AS interval_start, 
        '2012-05-26 11:59:59' AS interval_end, 
        0 AS creative_id, '2012-05-26 12:04:01' AS updated
    FROM
        (
        SELECT
            interval_start AS date_time, creative_id AS ad_id, zone_id AS zone_id,
            count AS clicks, 0 AS impressions, 0 AS requests
        FROM
            ox_data_bkt_c
        WHERE
            interval_start >= '2012-05-26 11:55:00'
            AN

The query mentioned does not try to insert the auto-incremented column data_intermediate_ad_id. It expects mysql to automatically add the next ID. When I checked the slave, I found a record for primary key 550696860.

Master is 5.0 and slave is 5.5.24

The second slave with version 5.5.21 is working fine. Is this a bug related to 5.5.24 version?

The query that has an issue is as follows:

INSERT INTO
                ox_data_intermediate_ad
                (date_time, ad_id, zone_id, clicks, impressions, requests, operation_interval, operation_interval_id, interval_start, interval_end, creative_id, updated)
            SELECT
                date_time, ad_id, zone_id, SUM(clicks) AS clicks, SUM(impressions) AS impressions, SUM(requests) AS requests, 5 AS operation_interval, 1591 AS operation_interval_id, '2012-05-25 12:35:00' AS interval_start, '2012-05-25 12:39:59' AS interval_end, 0 AS creative_id, '2012-05-25 12:43:01' AS updated
            FROM
                (
                SELECT
                    interval_start AS date_time, creative_id AS ad_id, zone_id AS zone_id, count AS clicks, 0 AS impressions, 0 AS requests
                FROM
                    ox_data_bkt_c
                WHERE
                    interval_start >= '2012-05-25 12:35:00'
                    AND
                    interval_start <= '2012-05-25 12:39:59' UNION ALL 
                SELECT
                    interval_start AS date_time, creative_id AS ad_id, zone_id AS zone_id, 0 AS clicks, count AS impressions, 0 AS requests
                FROM
                    ox_data_bkt_m
                WHERE
                    interval_start >= '2012-05-25 12:35:00'
                    AND
                    interval_start <= '2012-05-25 12:39:59' UNION ALL 
                SELECT
                    interval_start AS date_time, creative_id AS ad_id, zone_id AS zone_id, 0 AS clicks, 0 AS impressions, count AS requests
                FROM
                    ox_data_bkt_r
                WHERE
                    interval_start >= '2012-05-25 12:35:00'
                    AND
                    interval_start <= '2012-05-25 12:39:59'
                ) AS virtual_table
            GROUP BY
                date_time, ad_id, zone_id

I will like to know why does the slave has an issue with the insert into ... select statement.


Viewing all articles
Browse latest Browse all 17268

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>