zalando-nakadi / nakadi-producer-spring-boot-starter

Nakadi event producer as a Spring boot starter
MIT License
13 stars 8 forks source link

Possible risk: Database counter overflow #160

Open ePaul opened 1 year ago

ePaul commented 1 year ago

Background / Current situation

When the library sends out events:

The positive range of the 4-byte types is from 1 to 2147483647.

After producing this amount of events, the database sequence will refuse to produce more values, which means event production is broken.

A manual reset to negative values is possible, which then will result in the eid continuing from 00000000-0000-0000-ffff-ffff80000000 (counting up). When 0 is reached again (i.e. after reaching 00000000-0000-0000-ffff-ffffffffffff), it will start reuse the originally used eid values starting with 00000000-0000-0000-0000-000000000000, which also means that the sequence is then out of order.

Goal

We need to come up with a way of preventing this from happening.

Possible ideas:

ePaul commented 4 months ago

So now it happened the first time in an actual application (internal link).

It was decided to reset the counter to a negative value, to give a bit more time. Fortunately in this case it seems like nobody was using the eid for ordering purposes.

But this gives this a bit more urgency.