question

YONGHAN CHOI avatar image
YONGHAN CHOI asked

The behavior of the cloud script is very confusing because it works differently for each user

I make a Scheduled Task as follows.

Type of task: Run actions on each player in a segment

Segment: All Players

Actions:

- Type: Execute Cloud Script

- Dev_Event_ParseRankStatAndApplyAnother

- Check Publish results as PlayStream Event

- Cloud Script Function: Dev_Event_ParseRankStatAndApplyAnother

- Arguments: {"SrcRegionCode":"KR","DestRegionCode":"ASIA","IsTest":false}

And I've got all the players working with CloudScript.

Each user worked in two different ways.

And I delete the task,

I've created the same task and I've worked on it.

All the other users who had previously worked in two different ways,

now worked same and properly.

I'm very embarrassed.

In the meantime, I've had a lot of work done to the entire user as a schedule task.

But now I am completely unreliable about my work.

Question 1. What's the problem?

Question2. How can I check if this happens again in the future?




My Title ID: FC890

First Task Instance ID: 50D00A73EE9D08B

Second Task Instance ID: 1FCDBD2B87356CB1

Below Users normal operation result event.

- CFFD05245DF7B4

- 4653DFBC132195CF

...

Below Users malfunction operation result event.

- AE3753F4F6F805E5

- 492A6B9737690AAD

...

Below is the expected malfunction.

const Util =
{
    IsTest: false,


    Init_TestMode()
    {
        this.IsTest = true;
    },


...
...
...


}


handlers.Dev_Event_ParseRankStatAndApplyAnother = function (args, context) 
{
    let srcRegionCode = args["SrcRegionCode"];
    let destRegionCode = args["DestRegionCode"];


    let isTest = true;
    if(args.hasOwnProperty("IsTest"))
    {
        isTest = args["IsTest"];
    }
    if(isTest)
        Util.Init_TestMode();
...
...
...


let resultObj = {};
    if(Util.IsTest)
    {
        resultObj["URDataToUpdate"] = uRDataToUpdate;
    }
    return resultObj;
}

As an argument, we gave {"IsTest": false} to execute it.

At the top, the isTest should be false.

But Util.IsTest becomes true.

And,

if(Util.IsTest)

{ resultObj["URDataToUpdate"] = uRDataToUpdate; }

is executed and receives a function result from the result event.

This is not supposed to be done.

Below are the result events of the normal user and the result events of the malfunction user, respectively.

CFFD05245DF7B4 User Normal Operation Result Event

{
  "PlayFabEnvironment": {
    "Application": "logicserver",
    "Vertical": "master",
    "Commit": "1b7b02b",
    "Cloud": "main"
  },
  "CloudScriptExecutionResult": {
    "FunctionName": "Dev_Event_ParseRankStatAndApplyAnother",
    "ExecutionTimeSeconds": 0.0616742,
    "ProcessorTimeSeconds": 0.0,
    "MemoryConsumedBytes": 29024,
    "HttpRequestsIssued": 0,
    "APIRequestsIssued": 2,
    "FunctionResult": {},
    "Revision": 387,
    "Logs": []
  },
  "FunctionName": "Dev_Event_ParseRankStatAndApplyAnother",
  "EventNamespace": "com.playfab",
  "TitleId": "FC890",
  "EntityType": "player",
  "SourceType": "BackEnd",
  "TriggeringPlayer": {
    "PushNotificationRegistrations": [],
    "PlayerExperimentVariants": [],
    "VirtualCurrencyBalances": {
      "GD": 1442,
      "DM": 0,
      "FD": 150,
      "SP": 0,
      "EP": 1
    },
    "AdCampaignAttributions": [],
    "ContactEmailAddresses": [],
    "TitleId": "FC890",
    "LastLogin": "2020-07-24T05:46:06.7663505Z",
    "PlayerMemberships": [],
    "PlayerStatistics": [
      {
        "StatisticVersion": 10,
        "StatisticValue": 505,
        "Name": "MaxRankScore",
        "Id": "9173904A"
      },
      {
        "StatisticVersion": 10,
        "StatisticValue": 505,
        "Name": "KR",
        "Id": "BB6C4A46"
      },
      {
        "StatisticVersion": 10,
        "StatisticValue": -1,
        "Name": "KR_0",
        "Id": "1F1CCBCC"
      },
      {
        "StatisticVersion": 10,
        "StatisticValue": 505,
        "Name": "KR_1",
        "Id": "FCAF855A"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": -1,
        "Name": "KR_0",
        "Id": "1F1CCBCC"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": -1,
        "Name": "KR_1",
        "Id": "FCAF855A"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 1280,
        "Name": "KR",
        "Id": "BB6C4A46"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 1280,
        "Name": "KR_2",
        "Id": "65B863E"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": -1,
        "Name": "ASIA_0",
        "Id": "68BE0B3F"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 1843,
        "Name": "MaxRankScore",
        "Id": "9173904A"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 1843,
        "Name": "ASIA",
        "Id": "398F8CF"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 1843,
        "Name": "ASIA_2",
        "Id": "FCB796C1"
      },
      {
        "StatisticVersion": 0,
        "StatisticValue": 0,
        "Name": "LastEquip",
        "Id": "12E26200"
      }
    ],
    "LinkedAccounts": [
      {
        "PlatformUserId": "a951790185b448b4",
        "Platform": "AndroidDevice"
      }
    ],
    "ValuesToDate": {},
    "Origination": "AndroidDevice",
    "PublisherId": "3C4AB8DB9B800B6F",
    "DisplayName": "폭탄보이",
    "Statistics": {
      "MaxRankScore": 1843,
      "LastEquip": 0,
      "ASIA_0": -1,
      "ASIA": 1843,
      "KR_0": -1,
      "KR": 1280,
      "KR_1": -1,
      "ASIA_2": 1843,
      "KR_2": 1280
    },
    "Locations": {
      "LastLogin": {
        "ContinentCode": "AS",
        "CountryCode": "KR",
        "City": "Seoul"
      }
    },
    "PlayerId": "CFFD05245DF7B4",
    "Created": "2020-05-06T21:13:54.0379942Z",
    "Tags": []
  },
  "Timestamp": "2020-07-28T06:49:45.4824129Z",
  "EventName": "player_triggered_action_executed_cloudscript",
  "EntityId": "CFFD05245DF7B4",
  "EventId": "a321be36301d4393bd26603a8cf766e0",
  "Source": "CloudScript"
}

AE3753F4F6F805E5 User's malfunction result event

{
  "PlayFabEnvironment": {
    "Application": "logicserver",
    "Vertical": "master",
    "Commit": "1b7b02b",
    "Cloud": "main"
  },
  "CloudScriptExecutionResult": {
    "FunctionName": "Dev_Event_ParseRankStatAndApplyAnother",
    "ExecutionTimeSeconds": 0.0325673,
    "ProcessorTimeSeconds": 0.0,
    "MemoryConsumedBytes": 288880,
    "HttpRequestsIssued": 0,
    "APIRequestsIssued": 1,
    "FunctionResult": {
      "URDataToUpdate": {
        "RankStat": "{\"Datas\":[{\"Region\":\"ASIA\",\"Codes\":[\"11-2379-2379-180-151-96-15-10-0_0_0_0\"]},{\"Region\":\"AU\",\"Codes\":[]},{\"Region\":\"CAE\",\"Codes\":[]},{\"Region\":\"CN\",\"Codes\":[]},{\"Region\":\"EU\",\"Codes\":[]},{\"Region\":\"IN\",\"Codes\":[]},{\"Region\":\"JP\",\"Codes\":[]},{\"Region\":\"RU\",\"Codes\":[]},{\"Region\":\"RUE\",\"Codes\":[]},{\"Region\":\"SA\",\"Codes\":[]},{\"Region\":\"KR\",\"Codes\":[\"11-2379-2379-180-151-96-15-10-8_0_0_0\"]},{\"Region\":\"US\",\"Codes\":[]},{\"Region\":\"USW\",\"Codes\":[]}]}"
      }
    },
    "Revision": 387,
    "Logs": []
  },
  "FunctionName": "Dev_Event_ParseRankStatAndApplyAnother",
  "EventNamespace": "com.playfab",
  "TitleId": "FC890",
  "EntityType": "player",
  "SourceType": "BackEnd",
  "TriggeringPlayer": {
    "PushNotificationRegistrations": [],
    "PlayerExperimentVariants": [],
    "VirtualCurrencyBalances": {
      "GD": 632,
      "DM": 0,
      "FD": 150,
      "SP": 0,
      "EP": 2
    },
    "AdCampaignAttributions": [],
    "ContactEmailAddresses": [],
    "TitleId": "FC890",
    "LastLogin": "2020-07-22T05:13:19.6829632Z",
    "PlayerMemberships": [],
    "PlayerStatistics": [
      {
        "StatisticVersion": 11,
        "StatisticValue": -1,
        "Name": "KR_0",
        "Id": "1F1CCBCC"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": -1,
        "Name": "KR_1",
        "Id": "FCAF855A"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": -1,
        "Name": "KR_2",
        "Id": "65B863E"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 2379,
        "Name": "MaxRankScore",
        "Id": "9173904A"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 2379,
        "Name": "KR",
        "Id": "BB6C4A46"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 2379,
        "Name": "KR_3",
        "Id": "156801F"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 2379,
        "Name": "ASIA",
        "Id": "398F8CF"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": -1,
        "Name": "ASIA_0",
        "Id": "68BE0B3F"
      },
      {
        "StatisticVersion": 11,
        "StatisticValue": 2379,
        "Name": "ASIA_3",
        "Id": "D43A1A0D"
      },
      {
        "StatisticVersion": 0,
        "StatisticValue": 0,
        "Name": "LastEquip",
        "Id": "12E26200"
      }
    ],
    "LinkedAccounts": [
      {
        "PlatformUserId": "a93c749b85f3469d",
        "Platform": "AndroidDevice"
      }
    ],
    "ValuesToDate": {},
    "Origination": "AndroidDevice",
    "PublisherId": "3C4AB8DB9B800B6F",
    "DisplayName": "키루키루TV",
    "Statistics": {
      "MaxRankScore": 2379,
      "LastEquip": 0,
      "ASIA_0": -1,
      "ASIA": 2379,
      "KR_0": -1,
      "KR": 2379,
      "KR_1": -1,
      "KR_2": -1,
      "ASIA_3": 2379,
      "KR_3": 2379
    },
    "Locations": {
      "LastLogin": {
        "ContinentCode": "AS",
        "CountryCode": "KR",
        "City": "Namyangju"
      }
    },
    "PlayerId": "AE3753F4F6F805E5",
    "Created": "2020-07-04T10:44:48.3870948Z",
    "Tags": []
  },
  "Timestamp": "2020-07-28T06:47:34.9159267Z",
  "EventName": "player_triggered_action_executed_cloudscript",
  "EntityId": "AE3753F4F6F805E5",
  "EventId": "bc5d3a41152e4f789780b3054cd5cb7b",
  "Source": "CloudScript"
}
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

Bases on current information, I am not able to analyze the issue via raw data. May I have the detailed scenario?

  • What's the expected and actual behavior?
  • What does it mean by "Each user worked in two different ways"?

I have partially tested your code and can confirm that "Util.IsTest" will be updated along with "IsTest" changes in the argument. I don't see any issues there.

Does it mean that part of players in the same segment receive a different argument?

0 Likes 0 ·
YONGHAN CHOI avatar image YONGHAN CHOI Seth Du ♦ commented ·
  • What's the expected and actual behavior?

- Because i used {"SrcRegionCode":"KR","DestRegionCode":"ASIA","IsTest":false} as a argument in All Players Segment,

The following parts should not be executed for all players.

if(Util.IsTest)
{
	resultObj["URDataToUpdate"] = uRDataToUpdate;
}

  • What does it mean by "Each user worked in two different ways"?

- However, when I checked the function execution results in the event details,

1. Some users have executed that part.

2. Other users have not executed that part.

  • Does it mean that part of players in the same segment receive a different argument?

- That's what I expect. But I don't know if that's possible.

0 Likes 0 ·
Seth Du avatar image
Seth Du answered

For now, I cannot find anything corresponding to your issue. If necessary, please keep the scheduled task even it has issues so that we can look into and find where the problem is.

The argument is consistent and if isTest only changes with the value from argument, all players should have a consistent result as well. There cannot be 2 result except the value is changed by some other function.

According to the code you have shared, I don't think Util.IsTest is necessary because you may directly read isTest from the argument.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

YONGHAN CHOI avatar image YONGHAN CHOI commented ·
  • The argument is consistent and if isTest only changes with the value from argument, all players should have a consistent result as well. There cannot be 2 result except the value is changed by some other function.

- I think so, too.

As you can see in the code above, isTest only changes with the value from argument.

  • According to the code you have shared, I don't think Util.IsTest is necessary because you may directly read isTest from the argument.

- Util.IsTest is used globally in many functions.

Unless Util.IsTest is true, it actually modifies user data within several functions.

0 Likes 0 ·
YONGHAN CHOI avatar image YONGHAN CHOI commented ·
But the biggest problem right now is,

As described in the above post, the results actually came out differently.



PlayerIDs that I wrote down as a sample on the first post and

CloudScriptExecutionResult's FunctionResult shows that the event results are distinctly different.

I want you to focus on what is wrong with the actual results.

I've sampled a few people from 5,000 users of my title since the end of the task,

and the results have already been different.

If this was an important function related to the user's payment,

how could our team handle the resentment of countless people?

Is this problem not solved after all?

Because the schedule task has been deleted?

0 Likes 0 ·
YONGHAN CHOI avatar image
YONGHAN CHOI answered
  • The argument is consistent and if isTest only changes with the value from argument, all players should have a consistent result as well. There cannot be 2 result except the value is changed by some other function.

- I think so, too.

As you can see in the code above, isTest only changes with the value from argument.

  • According to the code you have shared, I don't think Util.IsTest is necessary because you may directly read isTest from the argument.

- Util.IsTest is used globally in many functions.

Unless Util.IsTest is true, it actually modifies user data within several functions.

But the biggest problem right now is,

As described in the above post, the results actually came out differently.




PlayerIDs that I wrote down as a sample on the first post and

CloudScriptExecutionResult's FunctionResult shows that the event results are distinctly different.

I want you to focus on what is wrong with the actual results.

I've sampled a few people from 5,000 users of my title since the end of the task,

and the results have already been different.

If this was an important function related to the user's payment,

how could our team handle the resentment of countless people?

Is this problem not solved after all?

Because the schedule task has been deleted?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

Can you still reproduce this issue? Please understand that to troubleshot, we will need the exact configuration and exclude all unnecessary factors to locate where the issue is. According to the codes you have provided, we are unknown to the behavior of constant Util and don't know if other functions involved when this issue happens.

If possible, would you share the detailed reproduction steps with the exact configuration of your title so that we can help.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.