New Slice 611704: Tax Transaction Value ID field changed to BigInteger to prevent IDENTITY exhaustion - #10314
Open
Tabrez Ajaz (v-ajaztabrez) wants to merge 2 commits into
Conversation
Table 20261 Tax Transaction Value primary key ID was Integer with SQL AutoIncrement. On large IN localization databases the IDENTITY sequence exceeded MaxInt (2,147,483,647), causing 'Arithmetic overflow error converting IDENTITY to data type int'. Posting Preview and rolled-back transactions consumed AutoIncrement IDs without committing rows, exhausting the range far beyond actual row count. Change ID to BigInteger and assign it from a BigInteger NumberSequence in the table OnInsert trigger (hosted in existing codeunit 20236 Transaction Value Helper, no new object). The sequence is lazily seeded from the current MAX(ID) on first use, so it never collides with existing rows, and NumberSequence natively supports the full BigInteger range. Persistent insert sites use Insert(true) so the trigger fires; temporary-table inserts are unaffected.
…it for Tax Transaction Value ID
| } | ||
| } | ||
|
|
||
| trigger OnInsert() |
Contributor
There was a problem hiding this comment.
The table now assigns "ID" only from OnInsert(), and the PR had to change internal callers from Insert() to Insert(true) to keep inserts working. Any dependent extension that previously inserted "Tax Transaction Value" with the parameterless Insert() and relied on AutoIncrement will now skip ID assignment and can fail with duplicate or zero primary-key values. Preserve the legacy insert contract or introduce a staged compatibility/deprecation path before removing the old behavior.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.33.4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AB#611704
Slice 611704: [Repair Item][IN] Change "Tax Transaction Value".ID to be BigInteger
Issue:
The primary key field
IDof table Tax Transaction Value (20261) wasIntegerwithAutoIncrement. On a production environment (IN localization, ~525 GB database) the SQL IDENTITY sequence exceeded the integer limit (2,147,483,647), causing the error: "Arithmetic overflow error converting IDENTITY to data type int." The actual row count (~285M) was well below the limit, but Posting Preview and failed/rolled-back transactions kept consuming AutoIncrement IDs without committing rows, exhausting the sequence far beyond the actual data.Cause:
SQL Server IDENTITY (AutoIncrement) is non-transactional — every insert attempt permanently increments the counter, even when the transaction is rolled back (Posting Preview, validation errors). Heavy use of Posting Preview consumed the integer range over time. The
Integertype has a maximum of only 2,147,483,647.Solution:
Changed field
IDfromIntegertoBigInteger, extending the range to 9.2 × 10¹⁸ (practically inexhaustible for this workload). RemovedAutoIncrementand moved ID assignment to the platformNumberSequenceAPI, which is natively BigInteger. Centralized ID generation in the existing helper Transaction Value Helper (20236) asGetNextTransactionValueID()— no new object introduced. The sequence is lazily seeded from the current MAX(ID) on first use (collision-free even on an upgraded database), with a TryFunction + ClearLastError guard for concurrent creation. The tableOnInserttrigger assigns the ID from the sequence (skipping temporary records and explicitly-set IDs). Live-table insert call sites (TaxRateComputation, TaxDocumentGLPosting) useInsert(true)so the trigger fires. The temp-tableNextIDvariable in TaxPostingBufferMgmt was changed to BigInteger to match the field type. Temporary table inserts manage their own IDs via simple counters and are unaffected by this change.