Issue Daily log rotation fails: "A table must have a primary key" on statisticsMeasurement, but plesk repair db finds no errors.

MCV

New Pleskian
Server operating system version
CentOS Linux 7.9.2009
Plesk version and microupdate number
18.0.74 #2
Hello,

I'm facing a persistent issue where the daily statistics processing and log rotation fails every night. This started happening a few days ago after server maintenance that involved multiple reboots.

Symptoms:

1. The web server log file access_ssl_log.processed.1.gz is not being updated. Its timestamp is several days old.
2. Every morning, I find that the access_ssl_log.processed file has been recreated with a size of 0 bytes.
3. As a result, all log data from the previous day is lost, and any scripts that rely on these rotated logs fail to run.

Root Cause Analysis:

I've traced the issue to a critical error in the Plesk panel log (/var/log/plesk/panel.log). Every night at the exact time of the failure (approx. 03:27 AM), the following error is logged:

[2025-12-04 03:27:18.054] ERR [panel] A table must have a primary key, but none was found for table 'statisticsMeasurement'

This error seems to halt the daily maintenance script, preventing it from processing and rotating the logs.

Troubleshooting Steps Performed:

Based on this error, I have tried the standard repair procedures, but they have not solved the problem:

1. I forced the daily maintenance script by running plesk daily -f. The command completes, but the logs are still not rotated.
2. I ran the database repair utility plesk repair db. The command reports that everything is [OK] and finds no errors to resolve.

[root@server ~]# plesk repair db

Checking the Plesk database using the native database server tools .. [OK]
Checking the structure of the Plesk database ........................ [OK]
Checking the consistency of the Plesk database ...................... [OK]

Error messages: 0; Warnings: 0; Errors resolved: 0

Conclusion:

There is a clear conflict: the panel.log proves that a core process is failing due to a missing primary key in the psa database, but the plesk repair db tool is unable to detect or fix this specific issue.

Since the automatic repair tool is not working, I am looking for guidance on how to safely resolve this database schema problem. My ultimate goal is to get the daily log rotation working again.

How can I repair the statisticsMeasurement table to unblock the daily maintenance script, especially when plesk repair db fails to see the issue?

Thank you for your assistance.

MCV
 
Hi, @MCV . I don't think 'statisticsMeasurement' belongs to the psa database. If I am right, it is normal for the repair tool not to detect any issue. Is the same error logged when you execute the maintenance task manually, please? Could you please try plesk daily ExecuteStatistics and confirm if any additional details are logged to the panel log file?
 
Hi Sebahat,

Thank you for your guidance. I have followed your suggestions and have some critical new findings to report.

First, I ran the command you suggested, plesk daily ExecuteStatistics. This command completed silently without any output, and it did not generate any new entries in the panel.log.

Since that command did not trigger the error, I tried a different approach and ran plesk daily --process-domains ... This second command successfully reproduced the error A table must have a primary key, but none was found for table 'statisticsMeasurement' in the panel log, on demand.

It's worth noting that this failure is specific to the access_ssl_log file. I can confirm that other logs, such as access_log.processed, are being rotated and processed correctly each night. The issue only seems to affect the SSL access log.

Following this, I conducted an exhaustive search across all databases for the table named statisticsMeasurement. The result is conclusive: the table does not exist. I also performed a broader search for any table containing %stat% or %measurement% in its name, and statisticsMeasurement was not found.

Conclusion:
The problem appears to be an application-level bug where a script fails on a table definition before the table itself is created.

As a final thought based on the evidence: I've noticed the problem started exactly on December 1st. As a hypothesis, could this be related to a monthly data aggregation task that runs at the beginning of a new month? It's just a theory, but it would seem to explain the timing of the initial failure.

At this point, it seems to be a bug or a corrupted schema file within Plesk itself. Could you please advise on the next steps? Is there a way to repair or re-install the specific component responsible for this task?

Thank you for your support.
 
Thank you for your update. The issue could be caused by a Plesk extension that uses a database and the same is missing, but the extension files remain. There are previous similar cases with the SSL It! extension. Could you please share the panel.log entries before the initial occurrence of the error?
 
Hi, and thanks for the follow-up.

Your hypothesis about a faulty extension seems spot on. I'm providing the last 10 lines from my `panel.log` file, which clearly show the ongoing issue.

These logs confirm the errors for `statisticsMeasurement` and, more importantly, also show several errors originating from the **Let's Encrypt** extension. These Let's Encrypt errors specifically point to missing primary keys for the `requestLog` table and issues with cleaning obsolete reports and collecting site information.

Here is the log snippet:

Code:
[2025-12-04 08:12:29.318] 24685:6931344224605 ERR [extension/letsencrypt] Unable to save request data to log while analyzing of the plain response
: A table must have a primary key, but none was found for table 'requestLog'
[2025-12-04 08:12:29.482] 24685:6931344224605 ERR [extension/letsencrypt] Unable to save request data to log while analyzing of the plain response
: A table must have a primary key, but none was found for table 'requestLog'
[2025-12-04 08:12:29.804] 24685:6931344224605 ERR [extension/letsencrypt] Unable to save request data to log while analyzing of the plain response
: A table must have a primary key, but none was found for table 'requestLog'
[2025-12-04 08:28:30.512] 32067:6931381e789bd ERR [panel] A table must have a primary key, but none was found for table 'statisticsMeasurement'
[2025-12-04 09:04:57.128] 16807:693140a91a92b ERR [panel] A table must have a primary key, but none was found for table 'statisticsMeasurement'
[2025-12-05 00:18:01.619] 22653:693216a9970b3 ERR [extension/letsencrypt] Failed to clean obsolete reports
[2025-12-05 00:18:01.654] 22653:693216a9970b3 ERR [extension/letsencrypt] Failed to collect site information
[2025-12-05 00:18:01.655] 22653:693216a9970b3 ERR [extension/letsencrypt] Failed to collect site information
[2025-12-05 03:34:57.788] 20657:693244d1bc802 ERR [panel] A table must have a primary key, but none was found for table 'statisticsMeasurement'
[2025-12-05 08:39:52.196] 28067:69328c482ba98 ERR [panel] A table must have a primary key, but none was found for table 'statisticsMeasurement'

Given you mentioned "SSL It!" and these logs strongly indicate problems within the "Let's Encrypt" extension, this feels like a significant lead.

What would you recommend as the next step? Is there a safe procedure to check, repair, or reinstall the Let's Encrypt extension to address its database tables?

Thanks again for the help.
 
Thank you for the additional details. I would recommend to re-install the Let's Encrypt:

Code:
plesk bin extension --uninstall letsencrypt
plesk bin extension --install letsencrypt

That will rebuild the extension database and should potentially fix the issue. Please do let us know if the same still continues after that.
 
Back
Top