Summary:ASTERISK-02402: voicemail file sequencing problem
Reporter:jjames (jjames)Labels:
Date Opened:2004-09-14 12:44:32Date Closed:2008-01-15 15:10:05.000-0600
Versions:Frequency of
Environment:Attachments:( 0) diffs.txt.diffs
Description:Voicemail requires all message files to be in sequence starting at index 0.  If the sequencing gets off (apparently multiple ways for this to happen), any messages beyond the first gap are irretrievable and the message waiting light remains active.  If in the future a voice mailbox gets enough messages to fill the gap in sequence numbers, the irretrievable messages become visible again and "old" messages that have never been heard before appear.

These symptoms cause users to have a lack of confidence in the voicemail system.


I have resolved the issue to my satisfaction by checking for sequencing problems before opening voice mailboxes.  If a sequencing error is detected, messages are re-indexed and processing then proceeds as usual.

While this solution does not seek out the root causes of sequence problems, it does make the voicemail system more robust and resilient to current and future bugs that break message sequence numbers and cause the voicemail application to appear unreliable to end users.

I am including a diff file with recommended changes.  I have tested these changes and currently use the modification in production environments.
Comments:By: Brian West (bkw918) 2004-09-14 12:56:23

Known issue.

By: Brian West (bkw918) 2004-09-14 13:28:41

no accually the ONLY way this gets whacked up is by using webvmail and its not doing the rightthing(tm) when it removes messages.  It should reorder them.  Voicemail does if you delete from inside of voicemail.


By: Mark Spencer (markster) 2004-09-14 15:36:55

Is this patch disclaimed?  It would also be nice to try to fix those things, but having a "built in fsck" for vmbox doesn't strike me as a bad idea given that it shouldn't generally have a performance penalty.

Would this do the right thing if someone copied files around and named them something like save-this-msg-0000.txt?  Is that something that would be unreasonable to worry about?

By: callguy (callguy) 2004-09-14 21:39:14

this is actually something i've run into a few times as well. i have multiple asterisk systems that are set to failover in sequence (both via my carrier, and via DNS SRV records for the user agents).

if the primary server goes down and users failover to the secondary it is seamless to them. however, if they get voicemail left on one of the failovers, there is the possibility of duplicate entries (i have all of the critical asterisk data mirrored between the servers).

one thing that i have considered would be creating an id based on seqno + datetime (or some other unique stamp). that coupled with an fsck like function would ensure that simply mirroring the files would always result in a consistent (at least from the end user standpoint) mailbox.

By: jjames (jjames) 2004-09-15 14:20:24

Regarding disclaiming the patch, no problem.  I just need to know how.

Regarding file format changes, I did not change the default handling of file formats.  The voicemail application expects files in a 7.3 format.

By: Mark Spencer (markster) 2004-09-15 14:31:24

There are links to the disclaimer at http://bugs.digium.com. Thanks!

By: Mark Spencer (markster) 2004-09-17 00:56:10

Did you get a chance to fill out the disclaimer?  Thanks!

By: Mark Spencer (markster) 2004-09-22 08:08:07

Unfortunately without confirmation of a disclaimer, we cannot apply the code, but  feel free to reopen the bug if you get a chance to submit a disclaimer or confirm you already haveone on file.  Thanks!

By: twisted (twisted) 2004-09-22 16:14:09

To discuss with Markster here at Astricon about disclamer and/or file disclaimer.  Spoke with jjames in person, and he mentioned the above.

edited on: 09-22-04 16:14

By: twisted (twisted) 2004-09-25 22:11:33

jjames, did you get a chance to talk to markster about this?

By: jjames (jjames) 2004-09-26 21:52:24

I emailed a disclaimer to mark for him to review.

By: daiy (daiy) 2004-09-29 11:08:56

I'm testing the patch, the function last_message_index in

if(vms->lastmsg != last_message_index(vms->curdir))

does not appear to be defined anywhere. Is it missing from the patch?

edited on: 09-29-04 11:09

By: jjames (jjames) 2004-09-29 12:12:40

Not sure how I dropped that function out.  Include the following:

static int last_message_index(char *dir)
       int x;
       char fn[256];
       for (x=0;x<MAXMSG;x++) {
               make_file(fn, sizeof(fn), dir, x);
               if (ast_fileexists(fn, NULL, NULL) < 1)
       return x-1;

By: daiy (daiy) 2004-09-29 12:25:15

With the missing function pasted in, the patch works great! I manually broke the sequence, and it fixed upon opening the vmbox. Thanks for the good work.!

Also, jjames, please update the patch to include the missing function. Hopefully this will be added to cvs soon.

By: Mark Spencer (markster) 2004-10-08 01:41:36

I think this is ready, but I didn't see the disclaimer, any chance of getting you to e-mail it again?

By: jjames (jjames) 2004-10-09 15:25:50

Emailed another disclaimer to mark on Friday morning.

By: Mark Spencer (markster) 2004-10-10 02:28:24

Got the disclaimer and it looks fine.  Will go ahead and merge this in, but please go ahead and fax a signed copy in at your convenience.  Thanks!

By: Russell Bryant (russell) 2004-10-11 21:38:51

added to the 1.0 branch

By: Digium Subversion (svnbot) 2008-01-15 15:09:57.000-0600

Repository: asterisk
Revision: 3969

U   trunk/apps/app_voicemail.c

r3969 | markster | 2008-01-15 15:09:56 -0600 (Tue, 15 Jan 2008) | 2 lines

Merge jjames's voicemail fixes (bug ASTERISK-2402)



By: Digium Subversion (svnbot) 2008-01-15 15:10:05.000-0600

Repository: asterisk
Revision: 3979

U   branches/v1-0/apps/app_voicemail.c

r3979 | russell | 2008-01-15 15:10:05 -0600 (Tue, 15 Jan 2008) | 2 lines

add check for incorrect voicemail sequencing (bug ASTERISK-2402)