Trouble with transaction_updates/3 and clause/3

Hello,

I am using transaction_update to get a record of clauses asserted during a transaction to protocol these into a log.

However, for some odd reason the last 5 clauses included the in the update list cause clause/3 to fail.

There is no apparent difference between these last give clause references and all the others.

Here is my code:

transaction_updates(Updates),			
map_clause(Updates, Updates_Clauses),

...

map_clause([], []).

map_clause([First_Ref | Rest_Refs], [Rest_Clauses]) :-
	First_Ref =.. [Functor, _Clause_Ref],
	Functor = erased,
	map_clause(Rest_Refs, Rest_Clauses).		 			

map_clause([First_Ref | Rest_Refs], [First_Clause | Rest_Clauses]) :-
	First_Ref =.. [_Functor, Clause_Ref],
	clause(Clause_Head, Clause_Body, Clause_Ref),
	First_Clause = (Clause_Head :- Clause_Body),
	format('Clause_Ref: assertz(~w) Clause: ~w :- ~w~n', [Clause_Ref, Clause_Head, Clause_Body]),
	map_clause(Rest_Refs, Rest_Clauses).		 			

% catches failed clause/3
map_clause([First_Ref | Rest_Refs], [Rest_Clauses]) :-
	trace,
	format('here: ~w~n', [First_Ref]),
	map_clause(Rest_Refs, Rest_Clauses).		 			

Here are the last five clauses written out:

here: assertz(<clause>(000000000761B420))
here: assertz(<clause>(000000000761B0C0))
here: assertz(<clause>(000000000761AC40))
here: assertz(<clause>(0000000007619860))
here: asserta(<clause>(000000000761A340))

Note: btw, erased clauses can not be retrieved with clause – i presume, one can get hold of them if a transaction is rolled back, but not before.

Has such a problem been reported before …

The give clauses found in the end are not generated by my code – i traced all clauses until the end of the transacted goal call, and up-to the last give clauses, everything is indeed generated.

So, its unclear which code actually generated those clauses.

Edit 2:

I now found these in the log:

(prolog_gui:trace_msg_id(19888):-true),
(prolog_gui:trace_msg_id(19823):-true),
(prolog_gui:trace_msg_id(19706):-true),
(prolog_gui:trace_msg_id(19827):-true)

Looks like these are the “culpit” – since i am tracing through the code, the tracer made some assertion as well :slight_smile:

With trace removed – those disappear.

@Jan, perhaps a bug (due to feature interaction between debugging and transaction logging) here …

I think what might be happening here is that those trace messages are erased from the KB, but they are still included in the trace – as asserted.

thanks,

Dan

Edit:
I now noticed that i do retract clauses – hence, they are found in the transaction record.