On 5/20/15, R.Smith <rsmith at rsweb.co.za> wrote: > > ANY solution that > relies on something not guaranteed is a bad solution.
Here is a disturbing truth: There are no guarantees. Those transistors that make up your CPU - they turn on and off when current is applied to their gate *with a certain probability*. The trick is to make that probability very close to 1.0 so that they overall system works reliably. Sometimes the probability of success is increased by running multiple subsystems in parallel and voting. This further increases the likelihood of a correct answer, but it is not a guarantee. The polarity of a magnetic domain on your disk drive is read by a passing read head with a certain probability, close to 1.0 but not quite as close as you might imagine. Sometimes bits are read incorrectly. Various error correcting codes increase the probability of a correct read-out, though they do not achieve certainty. Likewise, the charge on the floating gates in your SSD are read out probabilistically. Quite a few bits in the flash memory of your SSD are devoted to correcting read errors, and increasing the probability of a correct read. But that probability never quite reaches 1.0. The signals traveling through your network cable and bringing you this message are read with a finite reliability. Very sophisticated coding techniques are used to bring the probability of detecting a corrupted transmission to very near 1.0, so that bad packets can be discarded and retried. But those techniques are not perfect. They are not guaranteed. Everything about your computer is based on probabilities. Things are engineered so that the probabilities are very close to 1.0, and we are given the illusion that they are certainty. But they are not. Some people may say that such and such an algorithm is *guaranteed* to give the right answer. But that is true only under the assumption that the algorithm runs on a fault-free computer. And no such computer exists, and so the assumption is false. You can never make a perfect machine, or a perfect program, or a perfect system. The art of engineering is to get as close to perfection as you can, so that nobody notices the imperfections. The only guarantee you have is a negative: your system will eventually fail. Your job as a programmer, designer, or engineer, is to make the expected time to failure as large as possible. All that said, there exist scenarios where using a random number as an ID comes closer to guaranteeing that the ID is unique than any other technique you are likely to invent. -- D. Richard Hipp drh at sqlite.org