Discussions
Categories
- 385.5K All Categories
- 5.1K Data
- 2.5K Big Data Appliance
- 2.5K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
How to abort specific user sessions in RAC and stop the user to connect again to DB.

Hi,
We need to abort specific user sessions every night at 23:00 and stop the user to connect to the DB. Then allow the user to connect to the DB next day at 8:00.
I am new in Oracle. I only know I can kill user session by
alter system kill session 'SID,SERIAL#,@INST_ID' immediate;
But the problem is, KILL SESSION sometimes only mark a session as terminated and roll back ongoing transactions. It does not actually abort the transactions.
Is it possible to KILL SESSION something like abort all their transactions (we allow data loss for this user) ? And is there any way we can restrict the user to connect to DB?
Thank you very much😃
Answers
-
ALTER SYSTEM DISCONNECT SESSION '...' IMMEDIATE;
-
Thanks John, But alter system disconnect session .. immediate also will rollback data at background, right?
I want session is aborted and any processes in this session killed immediate .
Is it only can done by kill -9 in OS level? Thank you
-
No matter what you do (including kill -9) all uncommitted changes done by that session will be rolled back which can take long time. You will end up with a corrupt database otherwise.
SY.
-
Thanks Solomon Yakobson.
Then, How can i prevent the user to connect again to the DB after his sesssion is killed? Thank you.
-
A kill -9 is okay as Oracle system processes will clean up. DB corruption is unlikely - unless the kill is done of a non-user process. Oracle is pretty robust.
As for disallowing subsequent connections. Do you want to prevent any connections from a user device, or prevent logging in using a specific user schema?
The former can be done by using the firewall-cmd (OL7 and later) and block that IP from connecting to the listener port for an interim period. A cron job at 5pm that implement that as a non-permanent rule, and one at 8am that removes that rule.
The latter can be done by a database job that locks the Oracle user schema in the afternoon, and unlocks it in the morning.
-
I would use the Resource Manager. Schedule activation of a Resource Manager plan that sets the active session pool for that user's consumer group to zero.
-
Well, first we need to understand your application tearing. Are you using middle tier and all application users connect to database as same Oracle user and by "specific user" you mean application user? If so it can only be done on application side. In addition, unless I missed something, all suggested approaches will prevent new connection attempts. Existing sessions created before 23:00 will stay connected (inactive if using Resource Manager but still connected and therefore possibly locking some objects).
SY.
-
You should stop this user before 23:00 with a margin of the average rollback ; if it takes about 60 minutes in general, then kill that user at 22:00.
To prevent user from login : you need to either lock that user at specifict time and unlock it at specifict time ; or create a login trigger to do so.
-
I would use a login trigger to refuse connections for that user on the desired time frame, seems simpler than locking/unlocking the account or changing the resource manager limits.