19c has all sorts of goodies in this area but there is not an automated solution to handle this in 11g.
You could do something with a script, eg
SQL> select sid, serial#, last_call_et
2 from v$session
3 where sql_id = '0qht8ubcqk4wr' -- the "problem" SQL_ID
4 and status = 'ACTIVE'
5 order by 3;
SID SERIAL# LAST_CALL_ET
---------- ---------- ------------
497 744 38
136 13162 45
373 28703 52
3 rows selected.
That shows the sessions running the SQL and how long they've been running it for. So then you could do:
SQL> set serverout on
SQL> declare
2 l_threshold int := 1;
3 l_cnt int := 0;
4 begin
5 for i in (
6 select sid, serial#, last_call_et
7 from v$session
8 where sql_id = '0qht8ubcqk4wr'
9 and status = 'ACTIVE'
10 order by 3
11 )
12 loop
13 l_cnt := l_cnt + 1;
14 if l_cnt <= l_threshold then
15 dbms_output.put_line('Leaving SID='||i.sid||' untouched');
16 else
17 dbms_output.put_line('Killing SID='||i.sid);
18 -- execute immediate 'alter system kill session ....';
19 end if;
20 end loop;
21 end;
22 /
Leaving SID=497 untouched
Killing SID=136
Killing SID=373
PL/SQL procedure successfully completed.
and run that at a frequency that suits your needs