Common SQL Errors

MySQL Error 1868: ER_WARN_PURGE_LOG_IS_ACTIVE - How to Fix and Prevent

Galaxy Team
August 8, 2025

MySQL warns that a requested binary or relay log could not be purged because it is the file the server is currently writing to.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error ER_WARN_PURGE_LOG_IS_ACTIVE (1868)?

ER_WARN_PURGE_LOG_IS_ACTIVE (MySQL error 1868) means the PURGE command tried to remove the current active binary or relay log. Check the active log with SHOW MASTER STATUS and purge only older files to resolve the warning.

Error Highlights

Typical Error Message

ER_WARN_PURGE_LOG_IS_ACTIVE

Error Type

Maintenance Warning

Language

MySQL

Symbol

ER_WARN_PURGE_LOG_IS_ACTIVE was added in 5.7.2.

Error Code

1868

SQL State

HY000

Explanation

Table of Contents

What is MySQL error ER_WARN_PURGE_LOG_IS_ACTIVE (1868)?

MySQL returns warning 1868 with message "file %s was not purged because it is the active log file" when a PURGE BINARY LOGS or PURGE RELAY LOGS statement names the file currently being written.

The server skips that file, completes the purge on older logs, and issues SQLSTATE HY000 so administrators know why the target file remained.

What Causes This Error?

The newest binary or relay log is always open for writes. Any attempt to purge this active file conflicts with replication and durability guarantees, so MySQL blocks the deletion and raises the warning.

Automated rotation jobs that rely solely on timestamps or hard-coded filenames frequently select the active log by mistake, triggering error 1868.

How to Fix ER_WARN_PURGE_LOG_IS_ACTIVE

Locate the active log first. On a primary server run SHOW MASTER STATUS; on a replica run SHOW SLAVE STATUS or SHOW REPLICA STATUS. The File column shows the current log name.

Issue a PURGE BINARY LOGS TO 'mysql-bin.000123' command using the file just before the active one, or use PURGE BINARY LOGS BEFORE 'YYYY-MM-DD hh:mm:ss' with a safe timestamp.

Common Scenarios and Solutions

Manual cleanup - An admin copies the wrong filename. Re-run SHOW MASTER STATUS and purge only earlier files.

Cron job rotation - A script purges by date at midnight. Add a pre-check that compares the file list and excludes the last entry.

Best Practices to Avoid This Error

Embed SHOW MASTER STATUS in every rotation routine, dynamically building the PURGE statement so the active log is never referenced.

From MySQL 8.0, set binlog_expire_logs_seconds to let the server auto-expire logs, eliminating manual purges and the associated warnings.

Related Errors and Solutions

Error 1526 ER_BINLOG_PURGE_PROC_LOG closed - Occurs when the named log does not exist. Verify SHOW BINARY LOGS output.

Error 1372 ER_BINLOG_PURGE_EMFILE - Too many open files during purge. Raise the operating system file-descriptor limit or close idle sessions.

Common Causes

Purging the newest log by name

Administrators manually specify the highest numbered binlog without checking server status.

Date-based rotation window too aggressive

Scripts purge all logs older than a threshold that overlaps the active log's creation timestamp.

Replication lag miscalculation

On replicas, relay log rotation that ignores Relay_Master_Log_File purges the file still needed for replay.

Related Errors

ER_BINLOG_PURGE_PROC_LOG closed (1526)

The requested log file does not exist. Validate filenames with SHOW BINARY LOGS before issuing PURGE.

ER_BINLOG_PURGE_EMFILE (1372)

The server reached its open file limit while purging. Increase ulimit or open_files_limit to resolve.

ER_BINLOG_PURGE_FATAL_ERR

An internal purge failure stopped log deletion. Check error log for details and restart the purge after correction.

FAQs

Is error 1868 fatal or just a warning?

It is only a warning. The purge proceeds for eligible files and the server continues running normally.

Can I ignore ER_WARN_PURGE_LOG_IS_ACTIVE?

Ignoring it is generally safe, but repeated warnings signal that your rotation script targets the wrong file and should be fixed.

How does Galaxy help prevent this warning?

Galaxy's context-aware editor lets you embed SHOW MASTER STATUS in snippets, preview results, and generate correct PURGE commands, reducing human error.

Does setting binlog_expire_logs_seconds eliminate manual purges?

Yes. When configured, MySQL automatically removes expired logs without needing PURGE BINARY LOGS commands.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo