반응형
임시 테이블 생성으로 인해 2개 스크립트 대기 중입니다.
사용자 지정 제품 가져오기 스크립트(구성 가능하고 추가 속성, 범주 사진 등이 있는 단순한 제품 가져오기)를 실행하고 있습니다.
스크립트 실행 시 ($categories에는 카테고리 ID 배열 포함)을 사용하여 새로 생성된 제품에 카테고리를 할당할 때 이상한 "대기"가 발생합니다.
$categoryLinkRepository->assignProductToCategories($product->getSku(), $categories);
조사한 결과, 스크립트가 다음 함수에서 루프에 대해 두 번째를 실행할 때 지연이 시작된다는 것을 발견했습니다.
public function assignProductToCategories($productSku, array $categoryIds)
{
$product = $this->getProductRepository()->get($productSku);
$assignedCategories = $this->getProductResource()->getCategoryIds($product);
foreach (array_diff($assignedCategories, $categoryIds) as $categoryId) {
$this->getCategoryLinkRepository()->deleteByIds($categoryId, $productSku);
}
foreach (array_diff($categoryIds, $assignedCategories) as $categoryId) {
/** @var \Magento\Catalog\Api\Data\CategoryProductLinkInterface $categoryProductLink */
$categoryProductLink = $this->productLinkFactory->create();
$categoryProductLink->setSku($productSku);
$categoryProductLink->setCategoryId($categoryId);
$categoryProductLink->setPosition(0);
$this->getCategoryLinkRepository()->save($categoryProductLink);
}
$productCategoryIndexer = $this->getIndexerRegistry()->get(Indexer\Product\Category::INDEXER_ID);
if (!$productCategoryIndexer->isScheduled()) {
$productCategoryIndexer->reindexRow($product->getId());
}
return true;
}
이상한 것은 기존 제품에 대해서만 동일한 기능을 실행하면 새로 생성된 제품에 대해서만 지연이 발생한다는 것입니다.
서버의 Mysql 프로세스에 66초 동안 대기 중인 반복 쿼리가 표시됨
Sending data CREATE TEMPORARY TABLE `tmp_select_tUFtPSHTf3LaHnv19OnapfygPIfXxdCU` (PRIMARY KEY(`url_rewrite_id`),
이 문제는 운영 서버(MariaDB 10.3.16 실행)에서만 발생하고 로컬 개발 VM(Mysql 5.7)에서는 발생하지 않습니다.
서버의 mysql 구성과 관련된 문제인 것 같습니다.어떤 아이디어라도 환영합니다.
새 제품 저장은 해당 제품에 할당된 범주에 따라 해당 제품에 대해 url_rewrite에 항목을 작성하고 있기 때문에 기다리게 만드는 것 같습니다.
언급URL : https://stackoverflow.com/questions/56924479/magento-2-script-wait-due-to-create-temporary-table
반응형
'IT' 카테고리의 다른 글
Apache를 Node.js로 바꿀 수 있습니까? (0) | 2023.07.27 |
---|---|
Spring Boot에서는 머리가 없지만 Spring이나 플레인 자바에서는 머리가 없다고 Swing은 생각하는 이유는 무엇입니까? (0) | 2023.07.22 |
MySQL 유니언이 insert and select 문에서 작동하지 않습니다. (0) | 2023.07.22 |
__dict__ 속성 설명 (0) | 2023.07.22 |
plsql 루프 내에서 Oracle에 문자열 추가 (0) | 2023.07.22 |