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: SqliteJdbcSinkTest close in order #17849

Merged
merged 9 commits into from
Sep 28, 2022
Merged

Conversation

tisonkun
Copy link
Member

@tisonkun tisonkun commented Sep 27, 2022

This closes #17713.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

Matching PR in forked repository

PR in forked repository: tisonkun#3

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Sep 27, 2022
@tisonkun tisonkun changed the title fix: delete sqlite files after jdbc connection closed fix: SqliteJdbcSinkTest uses isolated file Sep 27, 2022
@tisonkun tisonkun changed the title fix: SqliteJdbcSinkTest uses isolated file fix: SqliteJdbcSinkTest uses isolated db file Sep 27, 2022
@tisonkun tisonkun changed the title fix: SqliteJdbcSinkTest uses isolated db file fix: SqliteJdbcSinkTest close in order Sep 27, 2022
@tisonkun
Copy link
Member Author

tisonkun commented Sep 27, 2022

cc @lhotari @poorbarcode

The root cause is that we run connection.commit concurrently in flush and close so it's possible that:

db.exec("commit;") // in flush
db.exec("commit;") // in close
db.exec("begin;") // in flush

so the second call failed with "no transaction is active".

The last commit in this patch can be overkill but it's a strong guarantee that we don't run into this situation (executor.shutdown doesn't cancel pending/running scheduled tasks). I'm glad to learn if we have a more lightweight solution (in-place sync for connection.commit? It looks a bit hacky for me XD).

NOTE: Before and after the last commit, all tests pass in about 3 seconds, no regression.

@tisonkun
Copy link
Member Author

I think I can use shutdown + awaitTermination here to simplify the code.

Copy link
Contributor

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

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

+1

@nicoloboschi
Copy link
Contributor

/pulsarbot rerun-failure-checks

@tisonkun
Copy link
Member Author

/pulsarbot rerun-failure-checks

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

Good work!

@lhotari lhotari merged commit c1ce3dd into apache:master Sep 28, 2022
@tisonkun tisonkun deleted the issue-17713 branch October 4, 2022 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs ready-to-test type/flaky-tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky-test: SqliteJdbcSinkTest.tearDown
4 participants