Нашел баг, написал о нем на почту, баг закрыли. Элементарное-человеческое “спасибо” – это мы не проходили. На полных правах публикую сообщение об ошибке.

Выбираю, что подарить человеку на день рождение. В итоге, подарок был куплен, но затем решил докупить сопроводилку в комплект.

На одной из страничек выскакивает довольно-таки заметное сообщение об ошибке, красным шрифтом, вижу перед собой sql-запрос. Потеряно соединение к мускулу во время запроса. Классика.

Пых, битрикс, мускул. Мне неизвестно, генерит ли сам битрикс такие sql-запросы, или это бедные студенты-извращенцы балуются на лабах. И да, это самый длинный sql-запрос, который я когда-либо видел. ORM, не, не слышали.

21 сентября 2014 года в 13:52 отсылаю на internetshop@re-store.ru письмо:

У вас ошибка в запросе к бд на странице http://www.re-store.ru/sale/:

FILE: /srv/re-store.ru/public_html/bitrix/modules/iblock/classes/mysql/iblockelement.php LINE: 735 MySQL Query Error: SELECT BE.ID as ID,BE.IBLOCK_ID as IBLOCK_ID,BE.NAME as NAME,BE.DETAIL_PICTURE as DETAIL_PICTURE,B.DETAIL_PAGE_URL as DETAIL_PAGE_URL, FPV0.VALUE as PROPERTY_ARTICUL_VALUE, FPV0.ID as PROPERTY_ARTICUL_VALUE_ID, FPV1.VALUE as PROPERTY_ARTICUL_2_VALUE, FPV1.ID as PROPERTY_ARTICUL_2_VALUE_ID, FPEN0.VALUE as PROPERTY_NEW_VALUE, FPEN0.ID as PROPERTY_NEW_ENUM_ID, FPV2.ID as PROPERTY_NEW_VALUE_ID, FPEN1.VALUE as PROPERTY_BRAND_VALUE, FPEN1.ID as PROPERTY_BRAND_ENUM_ID, FPV3.ID as PROPERTY_BRAND_VALUE_ID, FPV4.VALUE as PROPERTY_CAT_NAME_VALUE, FPV4.ID as PROPERTY_CAT_NAME_VALUE_ID, FPV5.VALUE as PROPERTY_OLD_PRICE_VALUE, FPV5.ID as PROPERTY_OLD_PRICE_VALUE_ID, FPV6.VALUE as PROPERTY_QUANTATY_ROZNICA_VALUE, FPV6.ID as PROPERTY_QUANTATY_ROZNICA_VALUE_ID, FPEN2.VALUE as PROPERTY_STATUS_VALUE, FPEN2.ID as PROPERTY_STATUS_ENUM_ID, FPV7.ID as PROPERTY_STATUS_VALUE_ID, FPV8.VALUE as PROPERTY_QUANTATY_VALUE, FPV8.ID as PROPERTY_QUANTATY_VALUE_ID, FPEN3.VALUE as PROPERTY_PREORDER_VALUE, FPEN3.ID as PROPERTY_PREORDER_ENUM_ID, FPV9.ID as PROPERTY_PREORDER_VALUE_ID, FPV10.VALUE as PROPERTY_PRICE_MOSKVA_VALUE, FPV10.ID as PROPERTY_PRICE_MOSKVA_VALUE_ID,L.DIR as LANG_DIR,BE.CODE as CODE,BE.XML_ID as EXTERNAL_ID,BE.IBLOCK_SECTION_ID as IBLOCK_SECTION_ID,B.IBLOCK_TYPE_ID as IBLOCK_TYPE_ID,B.CODE as IBLOCK_CODE,B.XML_ID as IBLOCK_EXTERNAL_ID,B.LID as LID , CAT_P2.ID as CATALOG_PRICE_ID_2, CAT_P2.CATALOG_GROUP_ID as CATALOG_GROUP_ID_2, CAT_P2.PRICE as CATALOG_PRICE_2, CAT_P2.CURRENCY as CATALOG_CURRENCY_2, CAT_P2.QUANTITY_FROM as CATALOG_QUANTITY_FROM_2, CAT_P2.QUANTITY_TO as CATALOG_QUANTITY_TO_2, ‘Цена ИМ’ as CATALOG_GROUP_NAME_2, ‘Y’ as CATALOG_CAN_ACCESS_2, ‘Y’ as CATALOG_CAN_BUY_2, CAT_P2.EXTRA_ID as CATALOG_EXTRA_ID_2, CAT_PR.QUANTITY as CATALOG_QUANTITY, IF (CAT_PR.QUANTITY_TRACE = ‘D’, ‘N’, CAT_PR.QUANTITY_TRACE) as CATALOG_QUANTITY_TRACE, CAT_PR.QUANTITY_TRACE as CATALOG_QUANTITY_TRACE_ORIG, IF (CAT_PR.CAN_BUY_ZERO = ‘D’, ‘N’, CAT_PR.CAN_BUY_ZERO) as CATALOG_CAN_BUY_ZERO, IF (CAT_PR.NEGATIVE_AMOUNT_TRACE = ‘D’, ‘N’, CAT_PR.NEGATIVE_AMOUNT_TRACE) as CATALOG_NEGATIVE_AMOUNT_TRACE, IF (CAT_PR.SUBSCRIBE = ‘D’, ‘Y’, CAT_PR.SUBSCRIBE) as CATALOG_SUBSCRIBE, IF ( CAT_PR.QUANTITY > 0 OR IF (CAT_PR.QUANTITY_TRACE = ‘D’, ‘N’, CAT_PR.QUANTITY_TRACE) = ‘N’ OR IF (CAT_PR.CAN_BUY_ZERO = ‘D’, ‘N’, CAT_PR.CAN_BUY_ZERO) = ‘Y’, ‘Y’, ‘N’ ) as CATALOG_AVAILABLE, CAT_PR.WEIGHT as CATALOG_WEIGHT, CAT_PR.WIDTH as CATALOG_WIDTH, CAT_PR.LENGTH as CATALOG_LENGTH, CAT_PR.HEIGHT as CATALOG_HEIGHT, CAT_PR.MEASURE as CATALOG_MEASURE, CAT_VAT.RATE as CATALOG_VAT, CAT_PR.VAT_INCLUDED as CATALOG_VAT_INCLUDED, CAT_PR.PRICE_TYPE as CATALOG_PRICE_TYPE, CAT_PR.RECUR_SCHEME_TYPE as CATALOG_RECUR_SCHEME_TYPE, CAT_PR.RECUR_SCHEME_LENGTH as CATALOG_RECUR_SCHEME_LENGTH, CAT_PR.TRIAL_PRICE_ID as CATALOG_TRIAL_PRICE_ID, CAT_PR.WITHOUT_ORDER as CATALOG_WITHOUT_ORDER, CAT_PR.SELECT_BEST_PRICE as CATALOG_SELECT_BEST_PRICE, CAT_PR.PURCHASING_PRICE as CATALOG_PURCHASING_PRICE, CAT_PR.PURCHASING_CURRENCY as CATALOG_PURCHASING_CURRENCY, CAT_PR.TYPE as CATALOG_TYPE FROM b_iblock B INNER JOIN b_lang L ON B.LID=L.LID INNER JOIN b_iblock_element BE ON BE.IBLOCK_ID = B.ID LEFT JOIN b_iblock_property FP0 ON FP0.IBLOCK_ID = B.ID AND FP0.CODE=’ARTICUL’ LEFT JOIN b_iblock_property FP1 ON FP1.IBLOCK_ID = B.ID AND FP1.CODE=’ARTICUL_2’ LEFT JOIN b_iblock_property FP2 ON FP2.IBLOCK_ID = B.ID AND FP2.CODE=’NEW’ LEFT JOIN b_iblock_property FP3 ON FP3.IBLOCK_ID = B.ID AND FP3.CODE=’BRAND’ LEFT JOIN b_iblock_property FP4 ON FP4.IBLOCK_ID = B.ID AND FP4.CODE=’CAT_NAME’ LEFT JOIN b_iblock_property FP5 ON FP5.IBLOCK_ID = B.ID AND FP5.CODE=’OLD_PRICE’ LEFT JOIN b_iblock_property FP6 ON FP6.IBLOCK_ID = B.ID AND FP6.CODE=’QUANTATY_ROZNICA’ LEFT JOIN b_iblock_property FP7 ON FP7.IBLOCK_ID = B.ID AND FP7.CODE=’STATUS’ LEFT JOIN b_iblock_property FP8 ON FP8.IBLOCK_ID = B.ID AND FP8.CODE=’QUANTATY’ LEFT JOIN b_iblock_property FP9 ON FP9.IBLOCK_ID = B.ID AND FP9.CODE=’PREORDER’ LEFT JOIN b_iblock_property FP10 ON FP10.IBLOCK_ID = B.ID AND FP10.CODE=’PRICE_MOSKVA’ INNER JOIN b_iblock_property FP11 ON FP11.IBLOCK_ID = B.ID AND FP11.CODE=’CATALOG_SHOW’ INNER JOIN b_iblock_property FP12 ON FP12.IBLOCK_ID = B.ID AND FP12.CODE=’STR_PRICE’ LEFT JOIN b_iblock_element_property FPV0 ON FPV0.IBLOCK_PROPERTY_ID = FP0.ID AND FPV0.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV1 ON FPV1.IBLOCK_PROPERTY_ID = FP1.ID AND FPV1.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV2 ON FPV2.IBLOCK_PROPERTY_ID = FP2.ID AND FPV2.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV3 ON FPV3.IBLOCK_PROPERTY_ID = FP3.ID AND FPV3.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV4 ON FPV4.IBLOCK_PROPERTY_ID = FP4.ID AND FPV4.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV5 ON FPV5.IBLOCK_PROPERTY_ID = FP5.ID AND FPV5.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV6 ON FPV6.IBLOCK_PROPERTY_ID = FP6.ID AND FPV6.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV7 ON FPV7.IBLOCK_PROPERTY_ID = FP7.ID AND FPV7.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV8 ON FPV8.IBLOCK_PROPERTY_ID = FP8.ID AND FPV8.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV9 ON FPV9.IBLOCK_PROPERTY_ID = FP9.ID AND FPV9.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_element_property FPV10 ON FPV10.IBLOCK_PROPERTY_ID = FP10.ID AND FPV10.IBLOCK_ELEMENT_ID = BE.ID INNER JOIN b_iblock_element_property FPV11 ON FPV11.IBLOCK_PROPERTY_ID = FP11.ID AND FPV11.IBLOCK_ELEMENT_ID = BE.ID INNER JOIN b_iblock_element_property FPV12 ON FPV12.IBLOCK_PROPERTY_ID = FP12.ID AND FPV12.IBLOCK_ELEMENT_ID = BE.ID LEFT JOIN b_iblock_property_enum FPEN0 ON FPEN0.PROPERTY_ID = FPV2.IBLOCK_PROPERTY_ID AND FPV2.VALUE_ENUM = FPEN0.ID LEFT JOIN b_iblock_property_enum FPEN1 ON FPEN1.PROPERTY_ID = FPV3.IBLOCK_PROPERTY_ID AND FPV3.VALUE_ENUM = FPEN1.ID LEFT JOIN b_iblock_property_enum FPEN2 ON FPEN2.PROPERTY_ID = FPV7.IBLOCK_PROPERTY_ID AND FPV7.VALUE_ENUM = FPEN2.ID LEFT JOIN b_iblock_property_enum FPEN3 ON FPEN3.PROPERTY_ID = FPV9.IBLOCK_PROPERTY_ID AND FPV9.VALUE_ENUM = FPEN3.ID LEFT JOIN b_catalog_price CAT_P2 ON (CAT_P2.PRODUCT_ID = BE.ID AND CAT_P2.CATALOG_GROUP_ID = 2) LEFT JOIN b_catalog_product CAT_PR ON (CAT_PR.ID = BE.ID) LEFT JOIN b_catalog_iblock CAT_IB ON ((CAT_PR.VAT_ID IS NULL OR CAT_PR.VAT_ID = 0) AND CAT_IB.IBLOCK_ID = BE.IBLOCK_ID) LEFT JOIN b_catalog_vat CAT_VAT ON (CAT_VAT.ID = IF((CAT_PR.VAT_ID IS NULL OR CAT_PR.VAT_ID = 0), CAT_IB.VAT_ID, CAT_PR.VAT_ID)) WHERE 1=1 AND ( (((BE.ACTIVE_TO >= now() OR BE.ACTIVE_TO IS NULL) AND (BE.ACTIVE_FROM <= now() OR BE.ACTIVE_FROM IS NULL))) AND ((((BE.ACTIVE=’Y’)))) AND ((((B.IBLOCK_TYPE_ID LIKE ‘Accessories’)))) AND ((((FPV11.VALUE = ‘Y’)))) AND ((((FPV12.VALUE LIKE ‘%70’)))) ) AND (((BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL))) ORDER BY CAT_P2.PRICE asc [Lost connection to MySQL server during query] DB query error. Please try later.

Ответа не последовало, да, понимаю, что сервер мог быть под нагрузкой, на серве с бд (если все отдельно расположено, не проверял) было мало памяти и прочее, прочее. Но ведь сообщения об ошибках нельзя отправлять клиенту. Может кто-то забыл закомментировать код перед продакшеном, или у переменной значение поменять (production=1, например, не знаю, как там дела с этим в битриксе обстоят).

Может быть, кому-то и пригодится..