-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Description
In syslog_partition_create() (functions.php:192), the query that checks whether a partition already exists hardcodes table_name='syslog' regardless of the $table parameter:
$exists = syslog_db_fetch_row("SELECT *
FROM `information_schema`.`partitions`
WHERE table_schema='" . $syslogdb_default . "'
AND partition_name='" . $cformat . "'
AND table_name='syslog' -- always 'syslog', ignores $table
AND table_name='syslog'
ORDER BY partition_ordinal_position");syslog_partition_manage() calls this function for both syslog and syslog_removed. When called for syslog_removed:
- The check queries
sysloginstead ofsyslog_removed - If
syslogalready has the partition, the check returns true and skips creation forsyslog_removed— leaving it without a partition - If
syslogdoes not have the partition yet, the check returns false and creation proceeds correctly, but the inverse scenario also fails
There is also a race condition: if two poller processes check simultaneously before either creates the partition, both pass the check and both attempt ALTER TABLE ... REORGANIZE PARTITION, producing the "Duplicate partition name" error seen in #199 (particularly on DST fall-back nights when the process runs twice within the same clock hour).
Fix
- Replace
table_name='syslog'withtable_name='$table'(or use a prepared statement). - Wrap the check-and-create in a
GET_LOCK()/RELEASE_LOCK()to prevent the race.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels