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: Multi-thread recreate view gives error #16188

Closed
1 of 2 tasks
rad-pat opened this issue Aug 5, 2024 · 0 comments · Fixed by #16465
Closed
1 of 2 tasks

bug: Multi-thread recreate view gives error #16188

rad-pat opened this issue Aug 5, 2024 · 0 comments · Fixed by #16465
Assignees
Labels
C-bug Category: something isn't working

Comments

@rad-pat
Copy link

rad-pat commented Aug 5, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Version

v1.2.597-nightly

What's Wrong?

When calling DROP/RECREATE same view in multiple threads, receive error

APIError: ResponseError with 2314: Drop table 'v' with drop_on time
[SQL: DROP VIEW IF EXISTS v]

How to Reproduce?

Python code to reproduce, spawn 30 threads here, but the number is required to cause the collision.

import sqlalchemy as sa
from concurrent.futures import ThreadPoolExecutor, as_completed

def recreate_view(con):
    with con.begin() as c:
        c.execute(sa.text('DROP VIEW IF EXISTS v'))
    with con.begin() as c:
        c.execute(sa.text('CREATE OR REPLACE VIEW v as SELECT a, b FROM t'))

def main():
    con = sa.create_engine('databend://root:pwd@databend-query/default?sslmode=disable')
    with con.begin() as c:
        c.execute(sa.text('DROP TABLE IF EXISTS t'))
        c.execute(sa.text('CREATE TABLE t (a int not null, b int not null)'))

    with ThreadPoolExecutor(max_workers=256) as executor:
        futures = []
        for _ in range(30):
            futures.append(executor.submit(recreate_view, con))

        for future in as_completed(futures):
            future.result()


if __name__ == '__main__':
    main()

Are you willing to submit PR?

  • Yes I am willing to submit a PR!
@rad-pat rad-pat added the C-bug Category: something isn't working label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants