Hướng dẫn cách Unlock Reindex trong Magento 2

Có thể trong quá trình index, bạn gặp phải một thông báo lỗi “… index is locked by another reindex process. Skipping.”. Lỗi này xảy ra là do loại index đó đã bị khóa và bạn sẽ không thể reindex được loại đó. Bất kể khi bạn cố gắng reindex thì nó sẽ luôn bị bỏ qua. Để khắc phục được lỗi trên, trong bài viết này mình sẽ hướng dẫn bạn cách Unlock(mở khóa) Reindex trong Magento 2.

Các bước để mở khóa(Unlock) Reindex trong Magento 2

Bước 1: Bạn tiến hành chạy lệnh reindex để xác định loại index bị khóa.

php bin/magento indexer:reindex

Bạn sẽ thấy ví dụ như sau

Design Config Grid index has been rebuilt successfully in 00:00:04
Customer Grid index has been rebuilt successfully in 00:00:06
Category Products index has been rebuilt successfully in 00:00:02
Product Categories index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:01
Product EAV index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:04
Stock index is locked by another reindex process. Skipping.
Catalog Rule Product index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00

Bước 2: Xem danh sách các loại index, cùng với tên index sẽ dùng cho bước mở khóa. Bạn dùng lệnh:

php bin/magento indexer:info

Kết quả nhận được:

design_config_grid                       Design Config Grid
customer_grid                            Customer Grid
catalog_category_product                 Category Products
catalog_product_category                 Product Categories
catalog_product_price                    Product Price
catalog_product_attribute                Product EAV
catalogsearch_fulltext                   Catalog Search
cataloginventory_stock                   Stock
catalogrule_rule                         Catalog Rule Product
catalogrule_product                      Catalog Product Rule

Bước 3: Mở khóa index trong từng trường hợp.

Để mở khóa tất cả các loại index, dùng lần lượt các lệnh:

php bin/magento indexer:reset
php bin/magento indexer:reindex

Để mở khóa chỉ định một loại index, sử dụng các lệnh sau với tên loại index bạn có thể dóng ở bước 2. Ví dụ bài viết này chúng ta cần mở khóa Stock index:

php bin/magento indexer:reset cataloginventory_stock
php bin/magento indexer:reindex cataloginventory_stock

Khi thành công bạn sẽ nhận được thông báo:

Stock index has been rebuilt successfully in 00:00:04

Như vậy là mình đã hướng dẫn xong cách Unlock Reindex trong Magento 2.

Cảm ơn bạn đã đọc bài viết.

Xem thêm các bài Hướng dẫn Magento 2.

5 1 vote
Article Rating

Callula Huy

Callula is the Marketing Executive at Magetop. With more than 5 years of copywriting under her belt, Callula is into creating valuable content that is straight to the point. Life student. Workaholic. Foreign languages and traveling aficionado.

Leave a Reply or put your Question here

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x