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

[BUG]After deleting and rebuilding tenants with the same name, the old data still exists #1311

Closed
lutengda opened this issue Jun 28, 2023 · 3 comments
Assignees
Labels
type/bug Something isn't working
Milestone

Comments

@lutengda
Copy link
Collaborator

Describe the bug

version: cnosdb 2.3.1, revision 74fdaa3
mode: singleton

nohup ./target/debug/cnosdb run --config ./config/config_8902.toml -M singleton &

The default cnosdb tenant and root user login:

./target/debug/cnosdb-cli

Create tenants and users:

CREATE TENANT tenant_a;
CREATE USER user_a;
ALTER TENANT tenant_a ADD USER user_a AS owner;

Log in with tenant a and user a:

./target/debug/cnosdb-cli --tenant "tenant_a" --user "user_a"

Build database, build table and write data:

create database db1;
CREATE TABLE air_a (visibility DOUBLE,temperature DOUBLE,pressure DOUBLE,TAGS(station));
INSERT INTO air_a (TIME, station, visibility, temperature, pressure) VALUES(1666165200290401000, 'XiaoMaiDao', 56, 69, 77);
image

The default cnosdb tenant and root user login:

./target/debug/cnosdb-cli

Remove tenants and users:

drop tenant tenant_a;
drop user user_a;

Create tenants and users with the same name again:

CREATE TENANT tenant_a;
CREATE USER user_a;
ALTER TENANT tenant_a ADD USER user_a AS owner;

Log in with tenant a and user a:

./target/debug/cnosdb-cli --tenant "tenant_a" --user "user_a"

You'll find that the old data is still there
image

To Reproduce

No response

Expected behavior

I believe that after deleting a tenant, even if a new tenant with the same name is created, the old data should not exist

Additional context

No response

@lutengda lutengda added the type/bug Something isn't working label Jun 28, 2023
@roseboy-liu roseboy-liu modified the milestones: 2.3.2, V2.4.0 Jun 29, 2023
@roseboy-liu roseboy-liu assigned lutengda and unassigned lutengda and yukkit Aug 7, 2023
@lutengda
Copy link
Collaborator Author

lutengda commented Aug 8, 2023

My advice:
When executing the SQL command drop tenant tenantA, the tenantA is marked as deleting status and the SQL command returns immediately. A background thread is started to delete the data. After the data is deleted, the metadata of tenantA is deleted. During this period, attempts to delete or create a tenant with the same name as tenantA will return a message indicating that it is being deleted. If the data deletion fails, an error log is printed. Subsequent attempts to delete or create a tenant with the same name as tenantA will return the same error message.

@lutengda
Copy link
Collaborator Author

lutengda commented Aug 9, 2023

I has another idea:
There are two resources under the tenant, role and database, so when you execute drop tenant tenantA, delete the role and database under tenantA, and then delete the tenantA metadata.
This plan is also consistent with other drops.

lutengda added a commit to lutengda/cnosdb that referenced this issue Aug 9, 2023
lutengda added a commit to lutengda/cnosdb that referenced this issue Aug 16, 2023
@lutengda
Copy link
Collaborator Author

when drop tenant, drop database and role in this tenant, so close this issue

zipper-meng pushed a commit that referenced this issue Sep 20, 2023
roseboy-liu pushed a commit that referenced this issue Sep 21, 2023
@h4ofanya h4ofanya mentioned this issue Jan 25, 2024
4 tasks
bartliu827 pushed a commit to bartliu827/cnosdb that referenced this issue Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants