Sequential Numbering across servers

Hi.

I know the question about sequential numbering has been asked many times. I also know that this generates some frustration amongst those who monitor these lists as it appears that people are not reading the FAQs etc., but as far as I can tell, from having read the FAQs, followed numerous links and searched the forums endlessly, no-one has answered this specific question effectively (or if they have, they have provided urls that no longer work…).

The situation in hand is an application that runs from multiple servers and needs sequential numbers to be generated upon creation of the document.

If I have missed a posting that has addressed this fully, then I apologise, but I really would appreciate it if anyone has an answer to this, as I can’t seem to see a way around it.

Thanks

Victoria

Subject: Sequential Numbering across servers

Victoria you are correct - sequential numbering has always been somewhat of a sticky issue. This is quite simply due to server synchronicity. In a nutshell (this may be information you know but for anyone reading) if users in two different regions create a document simultaneously on 2 different servers, and the documents are numbered on create, they both may potentially receive the same number. I have ‘skirted’ this issue in 3 ways successfully: (and in order of effectiveness):

  1. Create a separate database (nsf file) that is used solely for distributing numbers: On create, the remote server MUST contact this administration database (usually on a hub server) to obtain the number. This is 99.99% effective. NOTE: IF the user is on a local replica - this is useless.

  2. Install a logic to the numbering system: Numbers can be calculated and distributed from within the live database, if the number has a logical operator as part of it. For instance, if there are 3 servers, one in North America, one in Europe and one in Asia, your numbers could be prefixed with NA, EU and AS. This does result in 3 parallel streams of numbers but they are all still unique (by virtue of the prefix) and can be assigned on create.

  3. On create, immediately SAVE the document and assign the number for the most part This is less effective but can work - again the users must be connected and the databases must be on a very frequent replication schedule. In some cases, and depending on activity, this becomes less and less effective.

These are the only schemes I have found to be implemented easily. There are even more elaborate schemes out there, but I was never afforded the luxury of spending days or weeks of development on this apsect.

Additionally, I have found a number of examples, nsf templates and web-based (that is numbering generated during web submissions) examples of these on all the traditional sources (sandbox, dominodeveloper, etc.) some more elaborate than others. If you need any, please post a response here and I will post some additional sources.

This is my “two cents”

Good Luck !!!

Subject: RE: Sequential Numbering across servers

Thank you for this detailed response.

The second option is one I had considered but is not acceptable to the client as he wouldn’t be happy with parallel counts like this.

Also, option 3 would still have a risk element which is too great as this is a critical application.

The first option does interest me and is the one I have been considering myself, but wasn’t sure how to get working. I haven’t managed to get an agent to look up to a different server, and so I had written this off.

How have you retrieved the information from the other server? A Lotusscript agent? A lookup? I can’t get either to work…

Thanks again for your help

Victoria

Subject: RE: Sequential Numbering across servers

Victoria,

I’ve successfully developed an application using option one as suggested by Jon in the past. If you’re not in a hurry I can put a sample together for you and e-mail it later today.

Let me know.

Paul

Subject: RE: Sequential Numbering across servers

sorry for the delay…

the lookup numbering was accomplished using script but could have been done using formula language as well:

@dbLookup does give the option of specifying a server and database:

@dblookup(“notes:nocache”; “servername : database.nsf”; “viewname”, etc…

Using script, I got a handle to the numbering database by using the notessession class; session.getdatabase and went from there.

I placed the number script itself in the postopen event of the form and it called a function I had stored in the script library called nextnumber

For nextnumber I created a little function that searched the database (db.search) for the highest number, added 1 to the highest number it found and then passed it to the event. As you might expect, I was creating a document with the new number and saving it.

Notes: If your activity is low and replication frequent, you could probably get away with this in the same database. Also, there really isn’t a need to create a new document for every number, you could in just keep one document with a field that gets sequentially increased by one. I used that technique and just didn’t like it, that’s why I used the new doc technique and kept it in a separate database. I would guess that this would get a little slow after number 50,000 or so - but I never anticipated my numbers to go that high.

Let me know if this helps you out.

Subject: Sequential Numbering across servers

Victoria,

All three of Jon’s options are flawed.

Here are the options again:

  1. Create a separate database (nsf file) that is used solely for distributing numbers

This assumes that you can get a number and use it before the next user requests a number. In practice this is impossible. If you have a number of concurrent users the problem gets worse. If you have a number of servers the problem gets even worse still.

  1. Install a logic to the numbering system.

Possible but it must be very smart to work effectively.

  1. On create, immediately SAVE the document and assign the number for the most part.

This is very user UNFRIENDLY, since a lot of users change their mind and throw away the document they just created. If that happens you have a couple of new problems to deal with–one is how to get rid of the now useless document, and second you have gaps in the sequence number.

I use a variation of option 2, whereby the sequence number is a 10 digit number, the first four (4) digits represent the (current) year, the next digit represents the server of origin, and the last five (5) digits represent a sequence number.

You never get two numbers the same. Of course, you need to reset the number (programmatically) back to 1 at the beginning of each year.

Regards

Rolf Pfotenhauer

Subject: RE: Sequential Numbering across servers

Victoria,

I fully agree with Rolf.

If you want to implement option 2 (see Rolfs posting) maybe Xetrion Counter Manager at http://www.xetrion.com can help you.

Regards,

Verona

Subject: Sequential Numbering across servers

We should observe that there is no computing theory reason why sequential numbers are necessary. Even if one grants that they should be used, there is no further reason why those sequential numbers must have a constant increment. 2,3,5,7,11 are sequential numbers, but they don’t have a constant increment in between.

Further, if you want to rely on some type of “index” of numbers (which is what 1, 2, 3, 4…n really is) then you CANNOT do this reliably at create time. You must do it at initial save time. The problem is that you must reserve a given index point at the time you allocate it, so if you allocate at UI compose time, you have to reserve that number. Which means that if another user then composes another document, they have to be allocated the next number. If the first user then discards their created document, you end up missing an index position, and you’re no longer incrementing at a constant rate.

Further, even if you do increment by a constant rate, you can only maintain the integrity of such a scheme if you NEVER ALLOW DELETIONS.

The multiple server issue is a minor issue compared to the fact that you probably aren’t going to accurately and consistently be able to implement your spec anyway.

Subject: RE: Sequential Numbering across servers

Nathan,In theory you are correct, there is no reason for a number to be purely sequential. However, computing is the basis of achieving a better business outcome. Why after all do we use computers.

In the business mindset it is best to have a “user friendly” number. This translates to a sequential number since a user will always wonder " what happened to the missing number(s)", if they are not sequential.

I have used both extensively in my career, I would claim that a user will always choose a sequential number over a non-sequential number any day. It makes sense, they can remember a sequential number a LOT better.

As for --“CANNOT do this reliably at create time”, this too is an over simplification. You can , if you tell the user that the number displayed “on-screen” is tentative. That is, it gets computed AGAIN on SAVE. Therefore, 90% of the time it is correct, the other 10% of the time it is one, two, or more numbers further on.

Regards

Rolf Pfotenhauer

Subject: RE: Sequential Numbering across servers

“This translates to a sequential number since a user will always wonder " what happened to the missing number(s)”, if they are not sequential."

A user will wonder that if the numbers are presented as sequential. But there is NO REASON to do this in any of the hundred or so business applications I’ve built over the last 14 years. We deal with applications like email just fine without having sequential numbers as a reference. Your IM buddy list doesn’t have sequential numbers associated with it. And you probably know several dozen phone numbers off the top of your head, but do you wonder what happened to the missing numbers in between?

“I have used both extensively in my career, I would claim that a user will always choose a sequential number over a non-sequential number any day. It makes sense, they can remember a sequential number a LOT better.”

There is absolutely nothing that makes a sequential number more memorable than a non-sequential one. Again, phone numbers are not presented to people as sequential. Social Security numbers, ID numbers, bank account numbers – all of these are memorizable and easily represented, and yet the user of them has ZERO PERCEPTION of sequence in the numbers.

Of course a user will PICK to have sequential numbers at design time. They will do so because they think they need to understand the design of the application in terms of data presented in a list. But this serves absolutely no purpose. If the point is to present an easy moniker to, say, an purchase order – we would be better off if our application simply picked a random word from a dictionary and assigned that as the reference ID. It would be easier to remember “wireless” as your purchase order search mechanism than “049283.”

“Therefore, 90% of the time it is correct, the other 10% of the time it is one, two, or more numbers further on.”

If 10% of the time you present a number, it changes, then that’s exactly what I mean when I say you can’t do it “reliably.” That’s what the word means.