1. Jeff Wayt
  2. PowerServer
  3. Tuesday, 18 April 2023 14:31 PM UTC

I have a PFC application I migrated from 2017 R2 to 2022 and deployed as both Win32 target and Cloud target on my local machine. I began testing the proof of concept cloud app.

Windows retrieve fine, but when I try to add a record that uses PFC LINKAGE it gives me an duplicate key error. Doing the exact same thing in the Win32 app, it works fine. Debugging the cloud app, the app gave me "Transaction does not exist" as I stepped thru the pfc_save, even though it had to retrieve security, validate the user and menu access. Seems an artifact of debug, but it masks discovery of the issue.

I was able to add a simple, non-linkage row in a different PFC window successfully, so there is something about PFC Linkage that fails to translate. I can get duplicate key errors adding a single parent row & saving, or retrieving a parent and adding a child row.

Has anyone seen this? Is there something I need to do to the PFC, like using AFC? The literature says it supports PFC. The n_cst_dwsrv_linkage service was not modified.

Thanks in advance.

Jeff Wayt Accepted Answer Pending Moderation
  1. Friday, 21 April 2023 20:17 PM UTC
  2. PowerServer
  3. # 1

In the cloud environment the sqlpreview event does not fire. This is important for Linkage because it makes multiple passes to hit the style, bottomup_topdown, which deletes first, then inserts or updates next. Linkage aims to delete dependents first, then add parentage before children. If parent datawindows have both inserts and deletes Linkage sets which statement will fire and expects sqlpreview to skip others:
// Only perform the requested SQL (insert, update, delete) statements.
if (li_sqltype = CI_PreviewSelect) or &
    (li_sqltype = CI_PreviewInsert And Pos(is_UpdatesAllowed,"I")>0) or &
    (li_sqltype = CI_PreviewUpdate And Pos(is_UpdatesAllowed,"U")>0) or &
    (li_sqltype = CI_PreviewDelete And Pos(is_UpdatesAllowed,"D")>0) then
    // Allow the continuation of the SQL statement.    
else
    // Stop this SQL statement from being executed.
    // return 2 - Skip this request and execute the next request.
    return 2
end if

Instead, the INSERT executes Update(false, false). Then it makes a second pass for the Insert and gets a duplicate key.This leads me to conclude TOPDOWN (default) is safer, except for the less frequent deletes. Deletes might best work to discard child rows and cascade deletes in the database.

How do we know which buffer it will process? Is DELETE buffer always first?

Comment
There are no comments made yet.
Jeff Wayt Accepted Answer Pending Moderation
  1. Friday, 21 April 2023 16:29 PM UTC
  2. PowerServer
  3. # 2

Because the duplicate key happens in a PFC Linkage service and successfully updates a simple single pfc window, I set some breakpoints and use the Debug Project toolbar button of the cloud project. Rather than walking into a sqlpreview event, I get this error:

Transaction is timeout. Transaction ID: AE4651FA-79F8-4115-A3F4-28F8493C4AD3-10

No changes made to database.

This cuts short my ability to debug in the cloud environment. Timeout? Am I stepping thru debug too slow?  It's worth repeating the same code deployed as a Win32 app does not get the duplicate key error.

The console for Kestrel shows:

fail: PowerServer.Api.ServerApiController[0]
      'PowerServer.Api.ServerApiController.DataStoreUpdate (PowerServer.Api)' get result (
      {
        "IsSuccess": false,
        "RequestId": null,
        "AppName": "wastrak_cloud",
        "NameSpace": "Wastrak_cloud",
        "ErrorCode": 0,
        "ErrorMessage": "Violation of PRIMARY KEY constraint 'PK_TRANSPORTERS'. Cannot insert duplicate key in object 'dbo.TRANSPORTERS'. The duplicate key value is (XB).\r\nThe statement has been terminated."
      }).
Security Warning: The negotiated TLS 1.0 is an insecure protocol and is supported for backward compatibility only. The recommended protocol version is TLS 1.2 and later.
fail: PowerServer[0]
      Failed to commit because there is no available database connection or transaction    at ☼  .☻.MoveNext()
      --- End of stack trace from previous location ---
         at  .☻.MoveNext()
      --- End of stack trace from previous location ---
         at ♠  .☻.MoveNext()
fail: PowerServer.Api.ServerApiController[0]
      'PowerServer.Api.ServerApiController.CommitAndCreateTransaction (PowerServer.Api)' get result (
      {
        "IsSuccess": false,
        "RequestId": null,
        "AppName": "wastrak_cloud",
        "NameSpace": "Wastrak_cloud",
        "ErrorCode": 0,
        "ErrorMessage": "Failed to commit because there is no available database connection or transaction"
      }).
Since this works for a simple PFC u_dw I would rule out TLS 1.0 as a barrier on my local machine.

Comment
There are no comments made yet.
Jeff Wayt Accepted Answer Pending Moderation
  1. Tuesday, 18 April 2023 19:29 PM UTC
  2. PowerServer
  3. # 3

Chris! Thank you for your quick reply. I am installing release 1900 as I write this. Since I just downloaded PB 2022 last week, I didn't have an MR on my radar.

I looked at code xchange and I found and downloaded 2022 PFC. I'm going to inspect it.

I guess I am referring to the PowerClient App that downloads from the web server. When I run it, it looks like the interface is the same as my win32 app.

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 18 April 2023 20:47 PM UTC
Correct .. the only difference in PC Apps is that the App deployment is via a Web Server. However once the App is downloaded to the user's machine from the WS, it runs like a "native" 2-tier C/S App would that you compiled as an EXE and then manually deployed to the App user's machine.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 18 April 2023 18:34 PM UTC
  2. PowerServer
  3. # 4

Hi Jeff;

  Can you tell us ...

  1. Did you download the PB 2022 version of the PFC?
  2. Have you updated the PB IDE & runtime to MR build 1900?
  3. Are you referring to a PowerClient App or a PowerServer App when you say "cloud"?

Regards ... Chris

 

Comment
  1. John Fauss
  2. Wednesday, 19 April 2023 02:26 AM UTC
@Jeff - Can you also provide some additional information about the error(s), such as the name of the event/function, line #, and the full text of the error message?
  1. Helpful
There are no comments made yet.
Miller Rhodes Accepted Answer Pending Moderation
  1. Tuesday, 18 April 2023 16:36 PM UTC
  2. PowerServer
  3. # 5

We may be having the same problem so I'll be watching this

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.