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

[BugFix] Adding dynamic partition failure for one table may block other tables (backport #51440) #51665

Closed
wants to merge 1 commit into from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Oct 9, 2024

Why I'm doing:

This bug is introduced by #47106. It changes DdlException to SemanticException which leads to DynamicPartitionScheduler.executeDynamicPartitionForTable can't catch the DdlException if adding partition fails. As a result, the current round of scheduling will stop, and other tables' partitions will not be created.

A way to reproduce is as following. Create a partition named p20241008 explicitly which will conflict with the dynamic partition to create. Dynamic partition will report exception Getting analyzing error. Detail message: Duplicate partition name p20241008. Note that change p20241008 to the current day you execute the sql.

admin set frontend config ('dynamic_partition_check_interval_seconds' = '5');
admin set frontend config ('default_replication_num' = '1');

create database test;
CREATE TABLE test.site_access1(
    event_day DATE,
    site_id INT DEFAULT '10',
    city_code VARCHAR(100),
    user_name VARCHAR(32) DEFAULT '',
    pv BIGINT DEFAULT '0'
)
DUPLICATE KEY(event_day, site_id, city_code, user_name)
PARTITION BY RANGE(event_day)(
PARTITION p20241008 VALUES LESS THAN ("2020-03-25")
)
DISTRIBUTED BY HASH(event_day, site_id)
PROPERTIES(
    "dynamic_partition.enable" = "true",
    "dynamic_partition.time_unit" = "DAY",
    "dynamic_partition.end" = "3",
    "dynamic_partition.prefix" = "p",
    "dynamic_partition.history_partition_num" = "0"
);

What I'm doing:

catch Exception rather than DdlException in DynamicPartitionScheduler.executeDynamicPartitionForTable

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

This is an automatic backport of pull request #51440 done by [Mergify](https://mergify.com). ## Why I'm doing: This bug is introduced by #47106. It changes [`DdlException` to `SemanticException`](https://github.com//pull/47106/files#diff-d823bc00d682d8a36f2257a3ddcfa045cd2f248ef768d7f9fb0c9a53b039d82cR1035) which leads to `DynamicPartitionScheduler.executeDynamicPartitionForTable` can't catch the DdlException if adding partition fails. As a result, the current round of scheduling will stop, and other tables' partitions will not be created.

A way to reproduce is as following. Create a partition named p20241008 explicitly which will conflict with the dynamic partition to create. Dynamic partition will report exception Getting analyzing error. Detail message: Duplicate partition name p20241008. Note that change p20241008 to the current day you execute the sql.

admin set frontend config ('dynamic_partition_check_interval_seconds' = '5');
admin set frontend config ('default_replication_num' = '1');

create database test;
CREATE TABLE test.site_access1(
    event_day DATE,
    site_id INT DEFAULT '10',
    city_code VARCHAR(100),
    user_name VARCHAR(32) DEFAULT '',
    pv BIGINT DEFAULT '0'
)
DUPLICATE KEY(event_day, site_id, city_code, user_name)
PARTITION BY RANGE(event_day)(
PARTITION p20241008 VALUES LESS THAN ("2020-03-25")
)
DISTRIBUTED BY HASH(event_day, site_id)
PROPERTIES(
    "dynamic_partition.enable" = "true",
    "dynamic_partition.time_unit" = "DAY",
    "dynamic_partition.end" = "3",
    "dynamic_partition.prefix" = "p",
    "dynamic_partition.history_partition_num" = "0"
);

What I'm doing:

catch Exception rather than DdlException in DynamicPartitionScheduler.executeDynamicPartitionForTable

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

…er tables (#51440)

## Why I'm doing:
This bug is introduced by #47106. It changes [`DdlException` to `SemanticException`](https://github.com/StarRocks/starrocks/pull/47106/files#diff-d823bc00d682d8a36f2257a3ddcfa045cd2f248ef768d7f9fb0c9a53b039d82cR1035) which leads to `DynamicPartitionScheduler.executeDynamicPartitionForTable` can't catch the DdlException if adding partition fails. As a result, the current round of scheduling will stop, and other tables' partitions will not be created.

A way to reproduce is as following. Create a partition named  `p20241008` explicitly which will conflict with the dynamic partition to create.  Dynamic partition will report exception `Getting analyzing error. Detail message: Duplicate partition name p20241008`. Note that change `p20241008` to the current day you execute the sql.

```
admin set frontend config ('dynamic_partition_check_interval_seconds' = '5');
admin set frontend config ('default_replication_num' = '1');

create database test;
CREATE TABLE test.site_access1(
    event_day DATE,
    site_id INT DEFAULT '10',
    city_code VARCHAR(100),
    user_name VARCHAR(32) DEFAULT '',
    pv BIGINT DEFAULT '0'
)
DUPLICATE KEY(event_day, site_id, city_code, user_name)
PARTITION BY RANGE(event_day)(
PARTITION p20241008 VALUES LESS THAN ("2020-03-25")
)
DISTRIBUTED BY HASH(event_day, site_id)
PROPERTIES(
    "dynamic_partition.enable" = "true",
    "dynamic_partition.time_unit" = "DAY",
    "dynamic_partition.end" = "3",
    "dynamic_partition.prefix" = "p",
    "dynamic_partition.history_partition_num" = "0"
);
```

## What I'm doing:

catch `Exception` rather than `DdlException` in `DynamicPartitionScheduler.executeDynamicPartitionForTable`

Signed-off-by: PengFei Li <[email protected]>
(cherry picked from commit ca8502a)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/clone/DynamicPartitionScheduler.java
@mergify mergify bot added the conflicts label Oct 9, 2024
Copy link
Contributor Author

mergify bot commented Oct 9, 2024

Cherry-pick of ca8502a has failed:

On branch mergify/bp/branch-3.3/pr-51440
Your branch is up to date with 'origin/branch-3.3'.

You are currently cherry-picking commit ca8502a76b.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/test/java/com/starrocks/clone/DynamicPartitionSchedulerTest.java

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/clone/DynamicPartitionScheduler.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Copy link
Contributor Author

mergify bot commented Oct 9, 2024

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

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

Successfully merging this pull request may close these issues.

1 participant