Permalink
Browse files

[fix] db3: abort of a transaction

  • Loading branch information...
Raja
Raja committed Jul 6, 2011
1 parent 5929a5e commit 7d965b97056bd053e48949aeb3c49562fbbd168c
Showing with 23 additions and 3 deletions.
  1. +18 −0 database/db3/hldb.ml
  2. +2 −0 database/db3/hldb.mli
  3. +3 −3 database/db3/session.ml
View
@@ -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
View
@@ -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
View
@@ -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)
@@ -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
@@ -769,6 +768,7 @@ module DT = DbTypes
#<End>;
end
+
let really_commit t trans =
match t.session_lock with
| Some (transl, db) ->

0 comments on commit 7d965b9

Please sign in to comment.