tomtenac
asked on
SQL Server Merge Replication Using An Identity Column
Hello,
I have set up merge replication with a pocket pc running an embedded visual basic application. The application subscribes to our SQL Server, uses SQL Server CE, runs very well, and synchronizes with the database reliably.
The table that I'm publishing on SQL Server is a table used to store item movements in our ERP system (i.e. stock and warehouse location changes). The table is basically a queue for these movements and every 15 seconds it processes the movements in bulk.
The problem is that the SQL table has an identity column. I set my replication to automatically adjust the identity columns on the publisher and subscriber, so I have that running and no conflicts should occur. The problem is that I have webpages updating that table, in addition to the pocket pcs, and the webpages are NOT subscribers and NOT using replication. So my webpages often get this error...
The identity range managed by replication is full and must be updated by a replication agent. The INSERT conflict occurred in database...Sp_adjustpublis heridentit yrange can be called to get a new identity range.
I tried using the Sp_adjustpublisheridentity range store procedure before attempting an insert, but it did not correct the error. After sometime the error does go away, however. If I attempt the insert through the webpage, I get the error. If I attempt the webpage insert about three times, the transaction completes. But if all the rows are processed and removed from the table, my webpage errors everytime.
Recap...
1) Using SQL Replication on Pocket PCs running embedded VB and SQL Ce
2) Publisher is automatically adjusting identity column on subscribers and publisher
3) When webpage attempts to insert into empty table error occurs
Please help.
Thanks.
I have set up merge replication with a pocket pc running an embedded visual basic application. The application subscribes to our SQL Server, uses SQL Server CE, runs very well, and synchronizes with the database reliably.
The table that I'm publishing on SQL Server is a table used to store item movements in our ERP system (i.e. stock and warehouse location changes). The table is basically a queue for these movements and every 15 seconds it processes the movements in bulk.
The problem is that the SQL table has an identity column. I set my replication to automatically adjust the identity columns on the publisher and subscriber, so I have that running and no conflicts should occur. The problem is that I have webpages updating that table, in addition to the pocket pcs, and the webpages are NOT subscribers and NOT using replication. So my webpages often get this error...
The identity range managed by replication is full and must be updated by a replication agent. The INSERT conflict occurred in database...Sp_adjustpublis
I tried using the Sp_adjustpublisheridentity
Recap...
1) Using SQL Replication on Pocket PCs running embedded VB and SQL Ce
2) Publisher is automatically adjusting identity column on subscribers and publisher
3) When webpage attempts to insert into empty table error occurs
Please help.
Thanks.
you probably need to increase the number of ids allocated in the publication or ajust the percentage before a new range is allocated, or increase the replecation frequency.
ASKER
I have allocated the ids at 100 on both the publisher and the subscriber.
The percentage is set at 80.
But the problem occurs with minimal data entry.
For example, I enter ONE record into the table through the webpage, 15 seconds goes by, and a process will read all the records, process them, and delete the records from the table.
Now, after that record has been processed, if I enter ONE additional record into the table through the webpage, I receive the identity error.
But if I attempt and fail to insert it approximately three times through the webpage, it will succeed.
Inconceivable!!!
The percentage is set at 80.
But the problem occurs with minimal data entry.
For example, I enter ONE record into the table through the webpage, 15 seconds goes by, and a process will read all the records, process them, and delete the records from the table.
Now, after that record has been processed, if I enter ONE additional record into the table through the webpage, I receive the identity error.
But if I attempt and fail to insert it approximately three times through the webpage, it will succeed.
Inconceivable!!!
you say that " and a process will read all the records, process them, and delete the records from the table." do you mean that essentially the web entry stuff is buffered and then batch processed ?
ASKER
Correct. The web entry and replicated records are all batched, and we have a service running that will process the records at a given interval (we have set it to 15 seconds).
I have been investigating this, though. I think the identity range for the publisher is 4-100 or something like that, because a record will insert after three attempts without fail. I tried, yesterday, to simply type in data into the record through enterprise manager. When I did, it gave me the adjustpublisheridentityran ge error, until the forth attempt. On the forth attempt, the identity was set to 4.
I think what might be happening is that I may have set up replication while 3 records were in the table (so that means the next index would have been 4).
Now, I either have to reset the range or recreate the publication. Any ideas on which means to use?
I have been investigating this, though. I think the identity range for the publisher is 4-100 or something like that, because a record will insert after three attempts without fail. I tried, yesterday, to simply type in data into the record through enterprise manager. When I did, it gave me the adjustpublisheridentityran
I think what might be happening is that I may have set up replication while 3 records were in the table (so that means the next index would have been 4).
Now, I either have to reset the range or recreate the publication. Any ideas on which means to use?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I believe we have solved the problem. I reset my publication, and made sure that no records were left in the table. After that, I've encountered no problems inserting through the webpage and index starts at 1 instead of 4. Brilliant!!!
Thanks,
Tom
Thanks,
Tom
your welcome.
Its worth holding onto a script for your replication. Ive generally found that 9 times out of 10 if replication breaks the easiest approach is to remove it and add it back again.
Its worth holding onto a script for your replication. Ive generally found that 9 times out of 10 if replication breaks the easiest approach is to remove it and add it back again.
>holding onto a script for your replication... if replication breaks the easiest approach is to remove it and add it back again.
I agree. But without having it scripted, it's an error-prone pain, so definitely keep the scripts.
I agree. But without having it scripted, it's an error-prone pain, so definitely keep the scripts.