Provides a default listener when no listener is set by tdwu · Pull Request #3658 · h2database/h2database · GitHub
Skip to content

Provides a default listener when no listener is set#3658

Open
tdwu wants to merge 1 commit into
h2database:masterfrom
tdwu:master
Open

Provides a default listener when no listener is set#3658
tdwu wants to merge 1 commit into
h2database:masterfrom
tdwu:master

Conversation

@tdwu

@tdwu tdwu commented Oct 18, 2022

Copy link
Copy Markdown

Provides a default listener when no listener is set. And add parameters to know the exact event source.
Sometimes we need to manage and monitor the database as a server and adjust the database parameters when it happens.

For example, deleteFilesOnDisconnect is automatically set to true on the target node when the cluster is created. This can easily trigger the deletion of data files when the database is closed, resulting in the loss of data files and tables. We can correct the parameters through the listener

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

THREAD_SAFETY_VIOLATION: Read/Write race. Non-private method Database.setEventListenerClass(...) reads without synchronization from this.eventListener. Potentially races with write in method Database.removeSession(...).
Reporting because another access to the same memory occurs on a background thread, although this access may not.


ℹ️ Learn about @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Was this a good recommendation?
[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

@sonatype-lift

sonatype-lift Bot commented Oct 18, 2022

Copy link
Copy Markdown
Contributor

⚠️ 222 God Classes were detected by Lift in this project. Visit the Lift web console for more details.

@katzyn

katzyn commented Oct 18, 2022

Copy link
Copy Markdown
Contributor

Sorry, I think we cannot accept this pull request due to following reasons:

  1. org.h2.api.DatabaseEventListener is a part of API and we cannot change it in incompatible way, at least without a major release (3.0 or something like it).
  2. org.h2.engine.Database is not a part of API and applications should never do anything with it directly. It also may not be referenced from org.h2.api package.
  3. Presence of event listener changes behaviour of database even if it does nothing in its methods, so if someone will set a default, it can break some applications.

For example, deleteFilesOnDisconnect is automatically set to true on the target node when the cluster is created.

Clustering code in H2 was written a long time ago, and, unfortunately, it is implemented in a simple and naive way with significant design flaws. Here you're trying to work around some problem in it, but it will be far better to improve the implementation itself. Please, describe your problem in a new issue, maybe there are better options for its resolution.

@tdwu

tdwu commented Oct 19, 2022

Copy link
Copy Markdown
Author

Thank you very much for your quick feedback. I can understand what you said. It's necessary for the long-term development of the product and should not affect other people who are using it.

I have a point. On the server side, it provides EventListener class that also runs on the server, but cannot be configured by itself.
Instead, it is set when the client connects, which looks kind of strange. For most servers, it is necessary to configure by themself. (As a server, it is important you can handle somethings by yourself)
So, Can I recreate a PR to add a new feature only to set the default listener by the server? Or can you help implement this feature in your plan?

@grandinj

Copy link
Copy Markdown
Contributor

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