On Fri, Nov 5, 2010 at 6:50 AM, Nicolas <[email protected]> wrote:
> So here are my questions:
> - An easy (but not complete) recovery would be to simply drop the most
> recent binlog file and launch beanstalkd again. Would it work ?
As each job is individually deleted, that fact is recorded in the
binlog. It's possible to have delete records interleaved with other
jobs being created or altered, and these jobs would be lost. Also, as
you imply, there's no guarantee that all of the unwanted delete
commands are in the last binlog file.
Otherwise, yes it would work.
> - An complete recovery would be to detect in the binlog where the bad
> instructions began, and delete everything after that. I'm not sure
> it's a good idea, as the binlog files seem to have the same size, with
> a lot of empty lines.
That would work fine.
The files are the same size because each is padded at the end with 0
bytes. You can safely ignore these bytes (or truncate them, if you
wish).
> Also, I can't see any date before each
> instruction (to help me find where the bad instructions began). Is
> their a date per instruction ? Is it encoded in a binary format ?
There is no date or time in the file, since it wasn't designed for
point-in-time recovery.
The file format is not documented, other than in the code that reads
and writes it. (I plan to fix this eventually.) Here is a quick
summary.
All data is copied directly from memory to the binlog. In particular,
ints are stored in native byte order.
Each record is built in the struct iovec in function binlog_write_job
in binlog.c. A record has either 3 or 4 parts, as follows:
name_len name_bytes job_struct [body_bytes]
Name_len is a pointer-sized unsigned int.
Name_bytes is the tube name, name_len bytes long.
Job_struct is the first part of the job struct in job.h under the
comment "persistent fields".
Body_bytes is the job body, with length specified by job_struct field
body_size. It is present the first time each job occurs in the binlog.
kr
--
You received this message because you are subscribed to the Google Groups
"beanstalk-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/beanstalk-talk?hl=en.