Skip to content

Commit

Permalink
[fix] db3: abort of a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Raja committed Jul 6, 2011
1 parent 5929a5e commit 7d965b9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
18 changes: 18 additions & 0 deletions database/db3/hldb.ml
Expand Up @@ -745,3 +745,21 @@ type t = {
let eid, rev = get_eid_of_path db rev path in
try get_node_of_eid db rev eid, rev
with Not_found -> raise UnqualifiedPath

let update_aborted db trdb =
UidMap.resize db.node_of_uid (Uid.value db.next_uid);
EidMap.resize db.uid_of_eid (succ (Eid.value db.tcount));
let rec filter_rev max lst =
if Revision.compare (fst (RevisionMap.max lst)) max <= 0 then
lst
else
filter_rev max (RevisionMap.remove_last lst)
in


Eid.Map.iter (fun k _ ->
if Eid.compare k db.tcount <= 0 then
ignore (EidMap.add k (filter_rev db.rev (EidMap.find k db.uid_of_eid)) db.uid_of_eid)
) trdb.tmp_uid_of_eid;

db
2 changes: 2 additions & 0 deletions database/db3/hldb.mli
Expand Up @@ -118,3 +118,5 @@ val follow_path :
@return The path unwound at [original_rev].
*)
val follow_link : t -> Revision.t -> Path.t -> Path.t * Node.t

val update_aborted : t -> t -> t
6 changes: 3 additions & 3 deletions database/db3/session.ml
Expand Up @@ -663,9 +663,7 @@ module DT = DbTypes
end else begin
match t.session_lock with
| None ->
let cur_rev =
Revision.succ (Hldb.get_rev t.db_ref)
in
let cur_rev = Revision.succ (Hldb.get_rev t.db_ref) in
let db = _prepare_commit t.db_ref t.db_to_merge cur_rev trans in
t.session_lock <- Some (trans, db);
Some (trans, k)
Expand Down Expand Up @@ -761,6 +759,7 @@ module DT = DbTypes
t.db_to_merge <- shrink_db_to_merge t;
(* Release the lock. *)
t.session_lock <- None;
t.db_ref <- Hldb.update_aborted t.db_ref _db;
pop_trans_prepare t;
#<If>
Logger.log ~color:`magenta
Expand All @@ -769,6 +768,7 @@ module DT = DbTypes
#<End>;
end


let really_commit t trans =
match t.session_lock with
| Some (transl, db) ->
Expand Down

0 comments on commit 7d965b9

Please sign in to comment.