none
Smartdevice - UploadOnly fails every time RRS feed

Answers

  • try removing this line on the insert command:

    IF CHANGE_TRACKING_MIN_VALID_VERSION(object_id(N'dbo.MBEP')) > @sync_last_received_anchor RAISERROR (N'SQL Server Change Tracking has cleaned up tracking information for table ''%s''. To recover from this error, the client must reinitialize its local database and try again',16,3,N'dbo.MBEP')

    if this an upload only scenario, last_received_anchor will always be less since it's never set for upload only scenario.

    see similar post i have for upload scenario albeit not using SQL Change Tracking: http://jtabadero.spaces.live.com/blog/cns!BF49A449953D0591!1207.entry

    • Marked as answer by tom321 Thursday, July 22, 2010 6:45 AM
    Wednesday, July 21, 2010 4:18 AM
    Moderator

All replies

  • what is the exact conflict being logged?
    Sunday, July 18, 2010 2:51 PM
    Moderator
  • the logged conflict is an    ClientInsertServerInsert conflict.

    ...but this can no happen, as the clientid is a Guid.

    And as i said, it looks like the client tries to insert the row twice. The first insert on the server is ok, the second try raises the error. (..because finally the row is synced to the server, but also the conflict is raised)

    Monday, July 19, 2010 12:05 PM
  • if i understand it correctly, the first sync works right?

    then on subsequent sync, the client uploads the same changes again thus causing the conflict.

    it looks like the LastSentAnchor is not correctly being set on the client.

    Try looking at your client if the LastSentAnchor is changing in between syncs.

    Tuesday, July 20, 2010 1:37 AM
    Moderator
  • Hi June

    No sync works right. Also the first one doesn't work. But curiously all upload only sync tables are synced to the server, even if the conflict is raised.

    1) Insert row A at client (assume upload only table)

    2) Sync with Server, Conflict is raised (ClientInsertServerInsertconflict)

    3) After sync, Row A is nevertheless available on the server.

    Tuesday, July 20, 2010 3:25 AM
  • ClientInsertServerInsertconflict is actually a bit misleading. It may mean there is indeed a conflict or may not. If you look at the insert statement of Sync Fx, you will find that it is checking the Row count after the insert, if it's equal to zero, it will raise a conflict.

    so try to simulate an insert directly using SQL Management Studio using the same insert statement used by Sync Fx with data from your client and see if there are error/warnings

    Tuesday, July 20, 2010 4:33 AM
    Moderator
  • If you insert directly no error/warnings appear.

    So do you have any idea what i have to change now in sync fx? On bidirectional sync everything works fine...

    Tuesday, July 20, 2010 4:52 AM
  • what is the value of the rowcount?
    Tuesday, July 20, 2010 4:55 AM
    Moderator
  • Looks like there is no rowcount value; Parameter: @sync_row_count Value: Skipped since Not Input/InputOutput

     

    Using Command: ;WITH CHANGE_TRACKING_CONTEXT (@sync_client_id_binary) INSERT INTO dbo.MBEP ([MbepId], [MbekId], [MatId], [Qty], [Qty_old], [Charge], [TargetItemId], [CurrentItemId], [ZstatusId], [BagrId]) VALUES (@MbepId, @MbekId, @MatId, @Qty, @Qty_old, @Charge, @TargetItemId, @CurrentItemId, @ZstatusId, @BagrId) SET @sync_row_count = @@rowcount; IF CHANGE_TRACKING_MIN_VALID_VERSION(object_id(N'dbo.MBEP')) > @sync_last_received_anchor RAISERROR (N'SQL Server Change Tracking has cleaned up tracking information for table ''%s''. To recover from this error, the client must reinitialize its local database and try again',16,3,N'dbo.MBEP')
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @sync_client_id_binary Len: 16 Value: 3F-F2-0C-7A-26-A8-6F-4F-A6-41-D7-85-3A-B0-21-F2
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @sync_row_count Value: Skipped since Not Input/InputOutput
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @sync_last_received_anchor Value: 0
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Insert for row with Parameters:
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @MbepId Value: 340abd04-3b18-40dd-93d1-e81c0f35053a
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @MbekId Value: 058ca6a6-3a4c-4176-9789-804ea152bf38
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @MatId Value: e9837124-be37-4d2b-93c0-b20ffde0e969
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @Qty Value: -7.00
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @Qty_old Value: 10.00
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @Charge Value: NULL
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @TargetItemId Value: NULL
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @CurrentItemId Value: 22d7624e-41c2-4713-bc31-8458524af7c7
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @ZstatusId Len: 3 Value: CHN
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:039,    Parameter: @BagrId Value: NULL
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:131,    Insert could not be applied
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:132,    Parameter: @MbepId Value: 340abd04-3b18-40dd-93d1-e81c0f35053a
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:132, Using Command: SELECT dbo.MBEP.[MbepId], [MbekId], [MatId], [Qty], [Qty_old], [Charge], [TargetItemId], [CurrentItemId], [ZstatusId], [BagrId], CT.SYS_CHANGE_CONTEXT, CT.SYS_CHANGE_VERSION FROM dbo.MBEP JOIN CHANGETABLE(VERSION dbo.MBEP, ([MbepId]), (@MbepId)) CT  ON CT.[MbepId] = dbo.MBEP.[MbepId]
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:132,
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:140,    Client Insert-Server Insert Conflict Detected
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Server wins conflict
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Apply failed due to conflict
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Insert for row with Parameters:
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @MbepId Value: 9f070aeb-dc33-483b-846f-b81008de14b0
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @MbekId Value: 5035d739-4cc8-46e5-b996-a33bb8e2345e
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @MatId Value: e9837124-be37-4d2b-93c0-b20ffde0e969
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @Qty Value: 3.00
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @Qty_old Value: 0
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @Charge Value: NULL
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @TargetItemId Value: NULL
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @CurrentItemId Value: e04355e5-215c-4cde-9b65-7f871ae34db3
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @ZstatusId Len: 3 Value: ADD
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:142,    Parameter: @BagrId Value: NULL
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:145,    Insert could not be applied
    VERBOSE, w3wp, 3, 07/20/2010 07:31:16:145,    Parameter: @MbepId Value: 9f070aeb-dc33-483b-846f-b81008de14b0

    Tuesday, July 20, 2010 7:42 AM
  • 1. From the verbose output, we can capture the INSERT command with its corresponding parameters.  Can you try to make a manual insert on the SQL Server with the same input?  Are you going to see any TSQL failure?

    2. What is @MatId?

    3. Is [MbepId] the only column for Primary Key on table dbo.MBEP?  Do you possible have 2 rows with the same PK values inserted on the client device?

    Thanks.


    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Tuesday, July 20, 2010 6:54 PM
    Answerer
  • Hi!

    1) No i cannot insert this statement. Because even if a conflict is raised it is still transportet to the server. In my above trace you see the "Client Insert-Server Insert Conflict Detected"-->Nevertheless this row is available on the server after the sync (that's

    2) @matid is just a guid (but not important)

    3) mbepid is the primary key. (Guid.NewGuid() created by the Client)

    All entries in this Table are only created by the client, not by the server...and there is only one client (so far)

    Wednesday, July 21, 2010 3:32 AM
  • try removing this line on the insert command:

    IF CHANGE_TRACKING_MIN_VALID_VERSION(object_id(N'dbo.MBEP')) > @sync_last_received_anchor RAISERROR (N'SQL Server Change Tracking has cleaned up tracking information for table ''%s''. To recover from this error, the client must reinitialize its local database and try again',16,3,N'dbo.MBEP')

    if this an upload only scenario, last_received_anchor will always be less since it's never set for upload only scenario.

    see similar post i have for upload scenario albeit not using SQL Change Tracking: http://jtabadero.spaces.live.com/blog/cns!BF49A449953D0591!1207.entry

    • Marked as answer by tom321 Thursday, July 22, 2010 6:45 AM
    Wednesday, July 21, 2010 4:18 AM
    Moderator
  • Hi tom321,

    The following trace output would mean that a row was already present when inserting on the server. Can you please check and make sure that this not the case?

    "VERBOSE, w3wp, 3, 07/20/2010 07:31:16:140,    Client Insert-Server Insert Conflict Detected"

    Also can you check the Conflict and Error properties in the ApplyChangeFailed event and see if that information helps troubleshoot?

    Wednesday, July 21, 2010 5:58 PM
  • Hi JuneT

    Now it works, thanks to you.

    I deletet

    "IF CHANGE_TRACKING_MIN_VALID_VERSION(object_id(N'dbo.MBEP')) > @sync_last_received_anchor RAISERROR (N'SQL Server Change Tracking has cleaned up tracking information for table ''%s''. To recover from this error, the client must reinitialize its local database and try again',16,3,N'dbo.MBEP')"

    ...and now it works

    I already tried the things you wrote in your blog, but setting selectinsertcommand and selectupdatecommand to NULL didn't work for me. (There i got the error in getSchema() method)

    @Ganeshan

    The row was not present at time of synchronisation. The primary key is a generated GUID on the client and so actually there cannot be a ClientInsertServerInsert conflict..

    Thanks for your help

    Thursday, July 22, 2010 6:45 AM