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

ON DISCONNECT triggers are not executed during forced attachment shutdown #7042

Closed
ilya071294 opened this issue Nov 10, 2021 · 20 comments
Closed

Comments

@ilya071294
Copy link
Contributor

ilya071294 commented Nov 10, 2021

There are 4 cases of forced attachment shutdown:

  1. During server shutdown.
  2. During database shutdown (gfix -shut full -force 0).
  3. It's deleted from MON$ATTACHMENTS by another attachment.
  4. (FB4+) It's closed after idle timeout.

Currently ON DISCONNECT triggers are not executed in all of these cases. The first case is OK but in other cases it makes sense to execute triggers.

@ilya071294
Copy link
Contributor Author

I will prepare a PR.

@asfernandes
Copy link
Member

What if a ON DISCONNECT triggers enters in loop and never ends?

Will a second attempt to shutdown or delete the attachment will make it not run again?

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Nov 10, 2021 via email

@ilya071294
Copy link
Contributor Author

What if a ON DISCONNECT triggers enters in loop and never ends?

If we talk about the current situation in FB3, is there any way to shutdown an attachment which cannot get out of an endless loop in ON DISCONNECT trigger? I mean when the attachment is closed normally by itself.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Nov 10, 2021 via email

@hvlad
Copy link
Member

hvlad commented Nov 10, 2021

What if a ON DISCONNECT triggers enters in loop and never ends?
Will a second attempt to shutdown or delete the attachment will make it not run again?

In FB4+ best solution is timeout.

What kind of timeout do you mean here ?
Nor connection not statement timeouts is not active by default.

@hvlad
Copy link
Member

hvlad commented Nov 10, 2021

BTW, I'm unsure is it worth changing ON DISCONNECT triggers in FB3.

Of course.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Nov 10, 2021 via email

@hvlad
Copy link
Member

hvlad commented Nov 10, 2021

Yes, we can. With what value ?

@AlexPeshkoff
Copy link
Member

Looks like we want to run ON DISCONNECT triggers when database shutdown and when attachment is deleted from MON$ATTACHMENTS. What should be done in a case when that triggers runs too long? Can use of timeouts help?

@ilya071294
Copy link
Contributor Author

What should be done in a case when that triggers runs too long? Can use of timeouts help?

I don't like the solution with timeouts because in general case we don't know how long a trigger runs. Maybe it's better to have an ability to manually kill attachments which are hanging in ON DISCONNECT triggers.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Nov 11, 2021 via email

@aafemt
Copy link
Contributor

aafemt commented Nov 11, 2021 via email

@romansimakov
Copy link
Contributor

romansimakov commented Nov 11, 2021 via email

@aafemt
Copy link
Contributor

aafemt commented Nov 11, 2021 via email

@aafemt
Copy link
Contributor

aafemt commented Nov 11, 2021

If the server is shut down by critical UPS state (or even simple Windows shutdown) Firebird has to stop ASAP. We cannot let unpredictable user code to interfere and risk that OS just terminate Firebird processes with unwritten cache etc.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Nov 11, 2021 via email

@aafemt
Copy link
Contributor

aafemt commented Nov 11, 2021 via email

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Nov 11, 2021 via email

@pavel-zotov
Copy link

=== QA notes ===
Test not needed for this ticket: issues are covered by following tests in functional/trigger/database/ :

test_disconnect_02.py // ON DISCONNECT trigger must fire during database shutdown (gfix -shut full -force 0)
test_disconnect_03.py // ON DISCONNECT trigger must fire if attachment is deleted from MON$ATTACHMENTS by another attachment
test_disconnect_04.py // ON DISCONNECT trigger must fire if attachment is closed by IDLE timeout.
test_disconnect_05.py // ON DISCONNECT trigger and OnDisconnectTriggerTimeout expiration

NB. For unknown reason test_disconnect_05.py fails all runs on Linux (but passes fine on Windows).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants