Skip to content

Commit c8f4513

Browse files
PS-11001: Documentation
https://perconadev.atlassian.net/browse/PS-11001 'README.md' updated with the description of the 'list' and 'purge_binlog' commands.
1 parent 82a93cc commit c8f4513

1 file changed

Lines changed: 142 additions & 1 deletion

File tree

README.md

Lines changed: 142 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,27 @@ Please run
151151
./binlog_server version
152152
./binlog_server fetch <json_config_file>
153153
./binlog_server pull <json_config_file>
154+
./binlog_server list <json_config_file>
154155
./binlog_server search_by_timestamp <json_config_file> <timestamp>
155156
./binlog_server search_by_gtid_set <json_config_file> <gtid_set>
157+
./binlog_server purge_binlogs <binlog_name>
156158
```
157159
where
158160
`<json_config_file>` is a path to a JSON configuration file (described below),
159161
`<timestamp>` is a valid timestamp in ISO format (e.g. `2026-02-10T14:30:00`),
160-
`<gtid_set>` is a valid gtid set (e.g. `11111111-aaaa-1111-aaaa-111111111111:1:3, 22222222-bbbb-2222-bbbb-222222222222:1-6`).
162+
`<gtid_set>` is a valid gtid set (e.g. `11111111-aaaa-1111-aaaa-111111111111:1:3, 22222222-bbbb-2222-bbbb-222222222222:1-6`),
163+
`<binlog_name>` is a valid binlog file name without path (e.g. `binlog.000001`).
161164

162165
### Operation modes
163166

164167
Percona Binary Log Server utility can operate in five modes:
165168
- 'version'
169+
- 'list'
166170
- 'search_by_timestamp'
167171
- 'search_by_gtid_set'
168172
- 'fetch'
169173
- 'pull'
174+
- 'purge_binlogs'
170175

171176
#### 'version' operation mode
172177

@@ -180,6 +185,49 @@ may print
180185
0.3.0
181186
```
182187

188+
#### 'list' operation mode
189+
190+
In this mode the utility requires no extra parameters apart from the config file name and will print to the standard output the complete list of binlog files stored in the Binary Log Server data directory in their creation order.
191+
Along with the file name the output will also return its current size in bytes, timestamps, URI and optional initial / added GTIDs (when the replication is configured to use GTID mode).
192+
For instance,
193+
```bash
194+
./binlog_server list config.json
195+
```
196+
may print
197+
```json
198+
{
199+
"status": "success",
200+
"result": [
201+
{
202+
"name": "binlog.000001",
203+
"size": 134217728,
204+
"uri": "s3://binsrv-bucket/storage/binlog.000001",
205+
"min_timestamp": "2026-02-09T17:22:01",
206+
"max_timestamp": "2026-02-09T17:22:08",
207+
"previous_gtids": "",
208+
"added_gtids": "11111111-aaaa-1111-aaaa-111111111111:1-123456"
209+
},
210+
{
211+
"name": "binlog.000002",
212+
"size": 134217728,
213+
"uri": "s3://binsrv-bucket/storage/binlog.000002",
214+
"min_timestamp": "2026-02-09T17:22:08",
215+
"max_timestamp": "2026-02-09T17:22:09",
216+
"previous_gtids": "11111111-aaaa-1111-aaaa-111111111111:1-123456",
217+
"added_gtids": "11111111-aaaa-1111-aaaa-111111111111:123457-246912"
218+
}
219+
]
220+
}
221+
```
222+
If an error occurs,
223+
```json
224+
{
225+
"status": "error",
226+
"message": "<reason>"
227+
}
228+
```
229+
Unlike the `search_by_timestamp` and `search_by_gtid_set` subcommands, instead of reporting an error when the storage is empty, the `list` returns '"status": "success"' with an empty 'result' array.
230+
183231
#### 'search_by_timestamp' operation mode
184232

185233
In this mode the utility requires one additional command line parameter `<iso_timestamp>` and will print to the standard output the list of binlog files stored in the Binary Log Server data directory that have at least one event whose timestamp is less or equal to the provided `<iso_timestamp>`.
@@ -305,6 +353,99 @@ Any error (network issues, server down, out of space, etc) encountered in this m
305353
In this mode the utility continuously tries to connect to a remote MySQL server / switch to replication mode and read binary log events. After reading the very last one, the utility does not close the connection immediately but instead waits for `<connection.read_timeout>` seconds for the server to generate more events. If this period of time elapses, the utility closes the MySQL connection and enters the `idle` mode. In this mode it just waits for `<replication.idle_time>` seconds in disconnected state. After that another reconnection attempt is made and everything starts from the beginning.
306354
Any network-related error (network issues, server down, etc) encountered in this mode does not result in immediate termination of the program. Instead, another reconnection attempt is made. More serious errors (like out of space, etc.) cause program termination.
307355

356+
#### 'purge_binlogs' operation mode
357+
358+
In this mode the utility requires one additional command line parameter `<binlog_name>` and will remove every binlog file with sequence number less than or equal to the one extracted from the `<binlog_name>`. Specifying binlog name which is currently being written to (the most recent one) is not allowed.
359+
For instance, if the storage currently has
360+
```
361+
binlog.000001
362+
binlog.000002
363+
binlog.000003
364+
```
365+
invoking
366+
```bash
367+
./binlog_server purge_binlogs config.json binlog.000002
368+
```
369+
will delete
370+
```
371+
binlog.000001
372+
binlog.000002
373+
```
374+
and only
375+
```
376+
binlog.000003
377+
```
378+
will remain in the storage.
379+
The utility will return
380+
```json
381+
{
382+
"status": "success",
383+
"result": [
384+
{
385+
"name": "binlog.000001",
386+
"size": 134217728,
387+
"uri": "s3://binsrv-bucket/storage/binlog.000001",
388+
"min_timestamp": "2026-02-09T17:22:01",
389+
"max_timestamp": "2026-02-09T17:22:08",
390+
"previous_gtids": "",
391+
"added_gtids": "11111111-aaaa-1111-aaaa-111111111111:1-123456",
392+
},
393+
{
394+
"name": "binlog.000002",
395+
"size": 134217728,
396+
"uri": "s3://binsrv-bucket/storage/binlog.000002",
397+
"min_timestamp": "2026-02-09T17:22:08",
398+
"max_timestamp": "2026-02-09T17:22:09",
399+
"previous_gtids": "11111111-aaaa-1111-aaaa-111111111111:1-123456",
400+
"added_gtids": "11111111-aaaa-1111-aaaa-111111111111:123457-246912"
401+
}
402+
]
403+
}
404+
```
405+
406+
If an error occurs,
407+
```json
408+
{
409+
"status": "error",
410+
"message": "<reason>"
411+
}
412+
```
413+
The `<reason>` may be one of the following (but not limited to):
414+
- `binlog composite name is too short`
415+
- `cannot purge: target binlog name has a different base name than the binlog records in the storage`
416+
- `cannot purge: target binlog name is not present in the storage`
417+
- `cannot purge: target is the current tail binlog file; at least one binlog file must remain in the storage to preserve the resume position`
418+
419+
The logic of the `purge_binlogs` will try to do its best and delete all the files in the range. However, if an error occurs in the middle of this group delete operation, already deleted files cannot be restored. In this case we will return a result with the `status` key equal to `warning`, the `result` key that includes all the records of the files we were trying to delete and `message` key set to a description of what went wrong during this group delete operation.
420+
For instance,
421+
```json
422+
{
423+
"status": "warning",
424+
"result": [
425+
{
426+
"name": "binlog.000001",
427+
"size": 134217728,
428+
"uri": "s3://binsrv-bucket/storage/binlog.000001",
429+
"min_timestamp": "2026-02-09T17:22:01",
430+
"max_timestamp": "2026-02-09T17:22:08",
431+
"previous_gtids": "",
432+
"added_gtids": "11111111-aaaa-1111-aaaa-111111111111:1-123456",
433+
},
434+
{
435+
"name": "binlog.000002",
436+
"size": 134217728,
437+
"uri": "s3://binsrv-bucket/storage/binlog.000002",
438+
"min_timestamp": "2026-02-09T17:22:08",
439+
"max_timestamp": "2026-02-09T17:22:09",
440+
"previous_gtids": "11111111-aaaa-1111-aaaa-111111111111:1-123456",
441+
"added_gtids": "11111111-aaaa-1111-aaaa-111111111111:123457-246912"
442+
}
443+
],
444+
"message": "cannot delete binlog.000001"
445+
}
446+
```
447+
These responses with `status` set to `warning` can be considered as an indicator of partial success.
448+
308449
### JSON Configuration file
309450

310451
The Percona Binary Log Server configuration file has the following format.

0 commit comments

Comments
 (0)