Skip to content

Conversation

@TreeHunter9
Copy link
Contributor

Old code has a bug where if we already have a sweep instance running, and some one call sweep once more, allowSweepRun() will return false and we are gonna call clearSweepFlags(), that will reset sweep flags and release a sweep lock. This will open an opportunity to run a second sweep instance for both Super and Classic server.

@AlexPeshkoff
Copy link
Member

As far as I can see isc_sweep_concurrent_instance is returned to the client which started sweep. Where is is handled in a case when sweep started automatically? IMO it should be silently ignored.

@AlexPeshkoff AlexPeshkoff self-assigned this Nov 18, 2024
@TreeHunter9
Copy link
Contributor Author

TreeHunter9 commented Nov 18, 2024

As I can see, allowSweepThread() will not allow us to run auto sweep if we have concurrent instances, but I added a check for isc_sweep_concurrent_instance anyway, just in case.

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Nov 18, 2024

OK. I reviewed the code once again. Initial problem can be fixed much simpler:

diff --git a/src/jrd/tra.cpp b/src/jrd/tra.cpp
index 3acd848976..f289c0d923 100644
--- a/src/jrd/tra.cpp
+++ b/src/jrd/tra.cpp
@@ -1848,7 +1848,6 @@ void TRA_sweep(thread_db* tdbb)

        if (!dbb->allowSweepRun(tdbb))
        {
-               dbb->clearSweepFlags(tdbb);
                return;
        }

But suggested patch contains new feature - user is notified what happened, without it sweep silently finishes in a moment. But I do not understand - why no diags in cases of RO database and explicitly set ATT_no_cleanup? If you want to add diags for sweep startup failure all cases should better be taken into an account.

@TreeHunter9
Copy link
Contributor Author

If you want to add diags for sweep startup failure all cases should better be taken into an account.

Yeah, I agree. I will add more error messages.

@hvlad
Copy link
Member

hvlad commented Nov 18, 2024

But suggested patch contains new feature - user is notified what happened, without it sweep silently finishes in a moment.

How it works for auto-sweep ?

@AlexPeshkoff
Copy link
Member

But suggested patch contains new feature - user is notified what happened, without it sweep silently finishes in a moment.

How it works for auto-sweep ?

See
#8320 (comment)

@AlexPeshkoff AlexPeshkoff merged commit f9bed00 into FirebirdSQL:master Feb 11, 2025
24 checks passed
dyemanov pushed a commit that referenced this pull request Feb 24, 2025
* Do not allow run concurrent sweep instances

* Silently ignore error about concurrent sweep instance when we try to run auto sweep

* Add more error messages that describe a reason of failed sweep startup

* Pass ISC_STATUS instead of Arg::Gds to function

---------

Co-authored-by: Artyom Ivanov <[email protected]>
@mrotteveel mrotteveel changed the title Do not allow run concurrent sweep instances Do not allow concurrent run of sweep instances Jul 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants