Running NHibernate HiLo identifiers results in negative numbers

We are launching an ASP.NET database application that uses HiLo to generate identifiers for objects. In addition to this application, we have several websites using the same database. We see that we are running out of identifiers, and the identification column becomes a negative number.

We suspect this has something to do with the generator. Since several websites operate on top of the same code base and database, and probably the HiLo algorithm quickly starts to generate identifiers that are outside the bigint range (with a fast relative course).

Is it possible to configure the generator so that it also uses spaces (of which there are quite a lot) in Id sequences instead of explicitly increasing the value whenever it feels that it is necessary?

Will this be a solution? Or should we do something else?

+3
source share
3 answers

You can switch to the Guid.Comb generator , if possible, or use int64 for identifiers. Look here for the final decision as to which generator to use.

0
source

What is your max_lo configured for? The formula for generating id is as follows:

h = ( 0) l_size = l = ( 1)

ID = h * l_size + l

, max_lo ?

+1

, .

, , -.

, Identity, . , TSQL /.

Do you have a concept similar to UoW in your application? Because the drawback of generating an identity is that it will break UoW (early inserts to get an identifier). It could be a price worth paying.

In my case, the system can easily exist as a single node / application pool (this is multi-user mode in one database with a single common connection string and is designed to run as a single instance on the web server) m is going to check this before I go to the identifiers Database.

0
source

Source: https://habr.com/ru/post/1789015/


All Articles