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

Provide ability to calculate number of active attachments efficiently, without accessing MON$ tables [CORE5164] #5447

Open
firebird-automations opened this issue Mar 23, 2016 · 8 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: @pavel-zotov

It will be extremely useful for lot of testing purpoces (and not only for them) to get number of current sessions.
After discuss with dimitr following syntax seems to be appropriate for this:

select RDB$GET_CONTEXT('SYSTEM', 'SESSION_COUNT') from rdb$database;

PS. Please, add this ability not only in 4.0 but also in 2.5 and 3.0.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

summary: Provide ability for fast receive number of current attachments, WITHOUT querying monitoring or call fb_lock_print and parsing its output => Provide ability to calculate number of active attachments efficiently, without MON$ queries or parsing lock-print output

Version: 4.0 Initial [ 10621 ] =>

@dyemanov
Copy link
Member

What should happen if the session count is requested by non-locksmith user? Still returning a valid count may be considered a security risk. Return number of attachments belonging to the current user? Throw a permission error?

@AlexPeshkoff
Copy link
Member

AlexPeshkoff commented Sep 20, 2022

Such ability exists since IB times, but requires use of services:
./fbsvcmgr localhost:service_mgr user sysdba password masterkey info_svr_db_info
Databases:
Number of attachments: 1
Number of databases: 1
Database in use: /usr/home/firebird/HEAD/gen/Debug/firebird/examples/empbuild/employee.fdb
But it reports total attachments count, not per-database information.
Agree - from security POV that appears at least suspicious, and yes, we should no add new security problems.

I suggest to limit use of this new feature to locksmith. What system privilege do we plan to use? More or less OK are MONITOR_ANY_ATTACHMENT / TRACE_ANY_ATTACHMENT. Or may be new one?

@dyemanov
Copy link
Member

Solution using services does not work for Classic ;-) As for the expected privilege, I'd suggest either MONITOR_ANY_ATTACHMENT or some new privilege.

And one more question - should we return count of all attachments, including system ones? It would be consistent with MON$ tables, but I'm afraid this may be not really expected by users. If you get for example "3" as result and you know you're already connected yourself, does it mean there are other 2 connections or you're the only one connected and the rest are system attachments? You cannot know that from SESSION_COUNT alone. So perhaps only user sessions should be counted there.

@AlexPeshkoff
Copy link
Member

May be new one? SESSION_COUNT is definitely less dangerous info than MONITOR_ANY_ATTACHMENT.

In SESSION_COUNT we certainly should return count w/o system attachments. But who says we can't also have TOTAL_ATTACHMENTS context?

@dyemanov
Copy link
Member

USER_SESSION_COUNT / TOTAL_SESSION_COUNT ? And COUNT_ATTACHMENTS system privilege?

@AlexPeshkoff
Copy link
Member

Something like this... Though system attachments are hardly sessions.

@dyemanov dyemanov changed the title Provide ability to calculate number of active attachments efficiently, without MON$ queries or parsing lock-print output [CORE5164] Provide ability to calculate number of active attachments efficiently, without accessing MON$ tables [CORE5164] Oct 18, 2022
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

3 participants