Skip to content

Commit adf0aaa

Browse files
authored
Merge pull request #286 from jgebal/bugfix/autonomous_transaction_dirty_on_timeout
Fixed a bug where autonomous transaction could remain open if timeout…
2 parents e4245f0 + 482a609 commit adf0aaa

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

source/core/ut_output_buffer.pkb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,32 @@ create or replace package body ut_output_buffer is
5555
end;
5656

5757
function get_lines(a_reporter_id varchar2, a_timeout_sec naturaln := gc_max_wait_sec) return ut_varchar2_rows pipelined is
58-
pragma autonomous_transaction;
59-
l_results ut_varchar2_rows;
58+
l_buffer_data ut_varchar2_rows;
6059
l_wait_wait_time number(10,1) := 0;
6160
l_finished boolean := false;
62-
begin
63-
loop
61+
function get_data_from_buffer return ut_varchar2_rows is
62+
l_results ut_varchar2_rows;
63+
pragma autonomous_transaction;
64+
begin
6465
delete from (
6566
select *
6667
from ut_output_buffer_tmp where reporter_id = a_reporter_id order by message_id
6768
)
6869
returning text bulk collect into l_results;
69-
70+
commit;
71+
return l_results;
72+
end;
73+
begin
74+
loop
75+
l_buffer_data := get_data_from_buffer();
7076
--nothing fetched from output, wait and try again
71-
if l_results.count = 0 then
77+
if l_buffer_data.count = 0 then
7278
dbms_lock.sleep(gc_sleep_time);
7379
l_wait_wait_time := l_wait_wait_time + gc_sleep_time;
7480
else
75-
commit;
76-
for i in 1 .. l_results.count loop
77-
if l_results(i) is not null then
78-
pipe row(l_results(i));
81+
for i in 1 .. l_buffer_data.count loop
82+
if l_buffer_data(i) is not null then
83+
pipe row(l_buffer_data(i));
7984
else
8085
l_finished := true;
8186
exit;

0 commit comments

Comments
 (0)