首页 > 解决方案 > 调试文件访问错误

问题描述

我在一个 WordPress WooCommerce 商店工作,该商店在每次页面访问时都会创建很多失败的访问系统调用。strace 显示它尝试打开很多文件,但只收到 -1 ENOENT 返回码。它试图访问错误位置的资产或 php 文件。有 9000 个访问系统调用,其中超过 8200 个失败,以及 1800 个 lstat 调用,其中超过 1500 个失败。

这种行为似乎不是本网站独有的,但也发生在另一个使用 Bedrock 和 Sage 构建的 WordPress WooCommerce 页面上。

现在,如何调试哪些代码行触发了所有这些文件访问?

摘自strace -e trace=%file

[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/role-command/src/Automattic/WooCommerce/Admin/API/Init.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/scaffold-command/src/Automattic/WooCommerce/Admin/API/Init.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/search-replace-command/src/Automattic/WooCommerce/Admin/API/Init.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/server-command/src/Automattic/WooCommerce/Admin/API/Init.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/shell-command/src/Automattic/WooCommerce/Admin/API/Init.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/super-admin-command/src/Automattic/WooCommerce/Admin/API/Init.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/widget-command/src/Automattic/WooCommerce/Admin/API/Init.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/cache-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/checksum-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/config-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/core-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/cron-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/db-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/entity-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/eval-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/export-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/extension-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/import-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/language-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/media-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/package-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/rewrite-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/role-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)
[pid 32953] access("/home/user/project/vendor/composer/../wp-cli/scaffold-command/src/Automattic/WooCommerce/Admin/ReportExporter.php", F_OK) = -1 ENOENT (Datei oder Verzeichnis nicht gefunden)

输出strace -c

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 28,65    0,007754           0      9038      8278 access
 10,51    0,002844           1      1820      1535 lstat
 10,51    0,002844           1      1924         2 openat
 10,43    0,002824           0      3090         2 read
  8,52    0,002307           1      1945           close
  6,57    0,001778           1      1199           getcwd
  5,68    0,001536           0      2088           fstat
  3,69    0,000998           2       412           poll
  3,28    0,000887          10        85           getpid
  2,25    0,000608           4       143           rt_sigaction
  1,62    0,000439           1       301           sendto
  1,50    0,000405          17        23           epoll_wait
  1,46    0,000396           1       363           recvfrom
  1,17    0,000317           0       534         2 stat
  0,66    0,000179          10        17           write
  0,62    0,000168           0       464           lseek
  0,45    0,000122           1        74           mmap
  0,37    0,000099           4        22         2 getsockopt
  0,28    0,000075           5        14           socket
  0,26    0,000070          35         2           clone
  0,19    0,000051           0        57           mprotect
  0,18    0,000048          24         2           set_robust_list
  0,16    0,000042           5         8           sendmsg
  0,15    0,000041           2        16         4 setsockopt
  0,14    0,000039           0        45         6 connect
  0,11    0,000030           2        13           brk
  0,08    0,000022           7         3         1 madvise
  0,07    0,000019           1        15           fcntl
  0,06    0,000017           0        19           rt_sigprocmask
  0,05    0,000014           4         3         1 futex
  0,05    0,000013           0        22           munmap
  0,04    0,000012           6         2           getgid
  0,04    0,000011           2         4           socketpair
  0,04    0,000011           5         2           getuid
  0,04    0,000011           2         4           geteuid
  0,04    0,000011           5         2           getegid
  0,02    0,000005           5         1           accept
  0,02    0,000005           0        49           getdents64
  0,01    0,000004           1         4           setitimer
  0,01    0,000004           0        21           getsockname
  0,01    0,000003           1         2           getpeername
  0,01    0,000002           1         2           times
  0,00    0,000001           0         2           chdir
  0,00    0,000000           0         3           ioctl
  0,00    0,000000           0        20         3 recvmsg
  0,00    0,000000           0         1           shutdown
  0,00    0,000000           0         1           bind
  0,00    0,000000           0         2           uname
  0,00    0,000000           0         2           gettid
  0,00    0,000000           0         3           ppoll
  0,00    0,000000           0         1           sendmmsg
------ ----------- ----------- --------- --------- ----------------
100,00    0,027066           1     23889      9836 total

操作系统:Linux,内核版本 5.4.66

网络服务器:带有 php-fpm 的 nginx,PHP 版本 7.4.10

WordPress:版本 5.5.1,在基岩堆栈上

标签: phpwordpresswoocommerce

解决方案


推荐阅读