Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore chunks too short OR not not seems to pattern .00...N #1615

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

chernomor
Copy link

@chernomor chernomor commented Nov 7, 2024

I tried download backup from S3 and got error:

> GET /racktables-mysql-backup/20.00000000000000000000 HTTP/1.1
< HTTP/1.1 404 Not Found
xbcloud: S3 error message: <?xml version="1.0" encoding="UTF-8"?>
<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Resource>/racktables-mysql-backup/20.00000000000000000000</Resource><RequestId>07abc2ecb27c437f</RequestId></Error>
xbcloud: Download failed. Cannot download 20.00000000000000000000.

Some debug output for chunks processing:

241107 10:12:15 xbcloud: add key: '20241105-shrinked2/ddl_log.log.qp.00000000000000000001' 
241107 10:12:15 xbcloud: add key: '20241105-shrinked2/done' 
241107 10:12:15 xbcloud: add key: '20241105-shrinked2/ib_buffer_pool.qp.00000000000000000000' 
-- 
241107 10:12:15 xbcloud: Check chunk: '20241105-shrinked2/ddl_log.log.qp.00000000000000000001' 
241107 10:12:15 xbcloud: Append chunk: '20241105-shrinked2/ddl_log.log.qp' : 1 
241107 10:12:15 xbcloud: Check chunk: '20241105-shrinked2/done' 
241107 10:12:15 xbcloud: Append chunk: '20' : 41105

Chunk name '20241105-shrinked2/done' has 23 chars (but not contains '.'), so it splits to filename '20' and idx '241105-shrinked2/done', then atoll cast idx to '241105'.

File 'done' uploaded to bucket by my backup script as finish-flag.

I append checks for right placement for / also: it must be left side of '.'

Some debug output for invalid chunk_name_to_file_name():
241107 10:12:15 xbcloud: add key: '20241105-shrinked2/ddl_log.log.qp.00000000000000000001'
241107 10:12:15 xbcloud: add key: '20241105-shrinked2/done'
241107 10:12:15 xbcloud: add key: '20241105-shrinked2/ib_buffer_pool.qp.00000000000000000000'
--
241107 10:12:15 xbcloud: Check chunk: '20241105-shrinked2/ddl_log.log.qp.00000000000000000001'
241107 10:12:15 xbcloud: Append chunk: '20241105-shrinked2/ddl_log.log.qp' : 1
241107 10:12:15 xbcloud: Check chunk: '20241105-shrinked2/done'
241107 10:12:15 xbcloud: Append chunk: '20' : 41105

Chunk name '20241105-shrinked2/done' has 23 chars (but not contains '.'), so it splits to
filename '20' and idx '241105-shrinked2/done', then atoll cast idx to '241105'.
@it-percona-cla
Copy link

it-percona-cla commented Nov 7, 2024

CLA assistant check
All committers have signed the CLA.

@@ -1038,10 +1038,16 @@ bool xbcloud_put(Object_store *store, const std::string &container,
@return true in case of success or false otherwise */
bool chunk_name_to_file_name(const std::string &chunk_name,
std::string &file_name, my_off_t &idx) {
if (chunk_name.size() < 22 && chunk_name[chunk_name.size() - 21] != '.') {
if (chunk_name.size() < 22 || chunk_name[chunk_name.size() - 21] != '.') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was noted in another #1538. Technically, it is a problem but not seen in the real world because of the minimum prefix length uploaded.

We can accept this.

Comment on lines +1045 to +1050
auto slash_pos = chunk_name.find('/');
if (slash_pos && chunk_name.size() - slash_pos < 22) {
/* '/' must be placed left side from '.' */
return false;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I more interested to know about your done file.

  1. Why do you do it?
  2. Do you upload 'done' file for every chunk or file?
  3. Did you modify xbcloud logic to do it? If you are doing externally, do you do it after the backup is uploaded to S3?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay.

  1. file done uses as finish-flag in backup script to detect incompleted backup (I run xtrabackup on several replicas)
  2. file done is single file, it uploaded once time
  3. xbcloud not modified, done uploads when xbcloud successfully finished

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants