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

make warnings/logging capture threadsafe #108

Merged
merged 4 commits into from
May 11, 2023
Merged

Conversation

matthiasdiener
Copy link
Member

Fixes #106. Alternative to #107.

@matthiasdiener matthiasdiener self-assigned this May 10, 2023
@matthiasdiener
Copy link
Member Author

matthiasdiener commented May 10, 2023

What do you think @inducer ? This passes the two testcases in #106.

@matthiasdiener matthiasdiener marked this pull request as ready for review May 10, 2023 17:30

def save_warnings(self) -> None:
for w in self.warning_data:
self.db_conn.execute(
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems support for old schema versions was lost here.

Copy link
Member Author

@matthiasdiener matthiasdiener May 11, 2023

Choose a reason for hiding this comment

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

I can restore that support if you prefer, but is it useful to be able to write older schema versions? _set_up_schema is only able to create the newest schema version at the moment.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not opposed to entirely dropping that support even, but there have to be error messages that clarify what happened, not failures/incorrect execution of INSERT somewhere in the guts.

Copy link
Member Author

@matthiasdiener matthiasdiener May 11, 2023

Choose a reason for hiding this comment

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

Ok, I think I understand. In other words, warnings/logging capture should only be enabled for the latest schema version; if for some reason an older schema version is used, the capture should be disabled with a warning message?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or you can just error outright on open.

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you think of 30ed3fb?

Copy link
Collaborator

Choose a reason for hiding this comment

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

What I meant was to drop support for older schemas entirely, with an appropriate error message. Note that this should probably be a separate PR. At that point, all conditionals based on schema_version should probably go away.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I added this as issue #109.

Comment on lines 634 to 636
if self.schema_version < 3:
raise ValueError("Logging capture needs at least schema_version 3, "
f" got {self.schema_version}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't these be in capture_xxx?

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved them in cd8301f

@matthiasdiener matthiasdiener requested a review from inducer May 11, 2023 20:22
@matthiasdiener matthiasdiener merged commit a99f1db into main May 11, 2023
@matthiasdiener matthiasdiener deleted the warn-log-threadsafe branch May 11, 2023 20:58
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.

Logging capture runs afoul of thread safety
2 participants