Skip to content
Browse files

[fix] db: catch timestamp read exception

  • Loading branch information...
1 parent 71c1799 commit 36362cede76ef2feecfc2beada89641b3c0c0ff8 Raja committed Jul 8, 2011
Showing with 7 additions and 1 deletion.
  1. +1 −0 database/db3/io/dbTypes.ml
  2. +2 −0 database/db3/ioManager.ml
  3. +4 −1 database/db3/session.ml
View
1 database/db3/io/dbTypes.ml
@@ -169,6 +169,7 @@ exception CrashStateMap of uidmap posexc
exception CrashStateIndex of dbstate posexc
exception CrashTrans of transfile posexc
exception CrashUidRev of bool
+exception CrashTimestamp
(*
(* Unused *)
View
2 database/db3/ioManager.ml
@@ -745,12 +745,14 @@ let write_timestamp fm ts =
let read_timestamp fm rev =
(* 9 bytes are written for each revision *)
+ try
let pos = 9 * rev in
logfm fm "Read timestamp at %d (for rev %d)" pos rev;
F.seek_in fm F.Timestamp pos;
iscorrupted (F.read_char fm F.Timestamp) cc0;
let t = F.read_int64 fm F.Timestamp in
Time.milliseconds (Int64.to_int t)
+ with F.EOF | F.Corruption -> raise DT.CrashTimestamp
(* +++ UID REV +++ *)
(* Uid Rev file :
View
5 database/db3/session.ml
@@ -221,7 +221,10 @@ module DT = DbTypes
Logger.log ~color:`yellow
"DB : get timestamp for revision %s" (Revision.to_string rev)
#<End>;
- IoManager.read_timestamp t.file_manager (Revision.value rev)
+ try IoManager.read_timestamp t.file_manager (Revision.value rev)
+ with DT.CrashTimestamp ->
+ raise (DiskError (Printf.sprintf "Timestamp: try to read an uncommitted revision (%s vs %s)"
+ (Revision.to_string rev) (Revision.to_string dbrev)))
(************************************)

0 comments on commit 36362ce

Please sign in to comment.
Something went wrong with that request. Please try again.