cessda / cessda.cvs.two

Apache License 2.0
0 stars 2 forks source link

Adding new codes does not keep order #349

Closed cessda-bitbucket-importer closed 2 years ago

cessda-bitbucket-importer commented 2 years ago

Original report on BitBucket by Taina Jääskeläinen.


I added new ExerciseCV to the Editor in staging. Added three codes (Term1, Term2, Term3). After adding a new code and saving, the latest code is sometimes not visible.

https://vocabularies-staging.cessda.eu/editor/vocabulary/ExerciseCV

For example, after adding and saving a fourth code, I only see three terms: Terms 1-3.

After adding a fifth term, both Term4 and Term5 become visible in the table but not in the order entered. They should appear in the order entered. If the user wants to have a different order, they will use ‘Move code’ function. Now they appear in the order: Term 1, Term 2, Term 5, Term 4, Term 3.

You can test this by opening the vocabulary in staging and adding new codes to it with ‘Add code’ function.

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


The Exercise CV is no longer in staging. You can use Testing CV 2 for testing moving codes to wanted order and adding new codes. I have put numbers on the codes.

In short, the system should work like this:

  1. A new code added should always appear below all other codes. This is currently not always happening.
  2. If the user wants to change the location of the new code, they use ‘Move code’ function.
  3. Any new codes added and their subsequent moving should be saved, keeping the given order, when the user clicks on ‘Save’ and seen immediately in the table and in the exports.

I do not know why sometimes an added code does not appear in the export. Please check that this is not due to the export table not being cleared when the user navigates to some other tab, or that the export table is not updated when the user opens the tab.

I do not know why refreshing the page sometimes makes an added code disappear.

For you to test the problem: try to add code6, a child to it, and code7. Move code 8 to its rightful position as the last term. Try to get all codes in the right order, using the Add code and Move code buttons, and check at the end that the exports are correct.

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


Note that this is a blocker/critical issue.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


Taina, many thanks for the details. I’m testing it right now according to your guidelines.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


I’ll make my notes from the testing here:

Attempt 1

  1. went here: https://vocabularies-staging.cessda.eu/editor/vocabulary/TestingCV2
  2. clicked button “+ Add code”
  3. filling form with new code “code6” and descriptive term “#349/code6”
  4. clicked button “Save”
  5. got message in green “A new Code is created with identifier code6”
  6. the newly created code didn’t appear in the code list
  7. refreshed the browser and got “503 Service Unavailable” (maybe a maintenance in the brackground, after a while the staging was up)
  8. the new “code6” is not in the list, even after several refresh attempts

Attempt 2

  1. went here: https://vocabularies-staging.cessda.eu/editor/vocabulary/TestingCV2
  2. clicked button “+ Add code”
  3. filling form with new code “code6” and descriptive term “#349/code6-attempt02”. “code6” is highlighted in yellow in the form and listed as the last code
  4. clicked button “Save”
  5. got message in green “A new Code is created with identifier code6”
  6. now the both codes “code6” are displayed in the list of codes at the bottom. both codes have a little number “8” in front of them (maybe a concept.position - check it in the template). also “code3” and “code8” have the same ?position? number “4“.
  7. clicked on “code6”, both “code6” codes are highlighted in blue
  8. clicked on “+ Add code” to create a child for “code6”, but which…?
  9. clicked on “Insert as child“, saved new code as “child1”, got green message “A new Code is created with identifier code6.child1“. there’s no child in the list.
  10. reloaded page in the browser, but the “child1” didn’t appear in the list
  11. trying again to create a child for “code6”. clicked on “code6” in the list, both codes “code6” are highlighted
  12. clicked on “Insert as child“ and filled form for “child2”. the preview at the bottom shows “child2” for both “code6” codes.
  13. clicked “Save” and got green message “A new Code is created with identifier code6.child2”
  14. there’s no “child2” under any of the “code6“ codes
  15. reloaded page in the browser
  16. no change. children “child1“ and “child2” for both “code6” code are missing
  17. tried to create “code7”, got green message, that it was created, but there was no “code7” in the list even after several page reloads.
  18. tried to create “code7” again, but got an error message in the form, that the “code7 exists”, hit cancel and “code7” together with children “child1“ and “child2” (for both codes “code6”) appeared in the list

Attempt 3

Possible causes of the bug and discoveries

Local tests

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


Stefan, your results are the same as mine. I added a new code in staging and saved. If I remember correctly, the new code does not necessarily reappear in the table, even when clicking on refresh. When I added another new code, then the new code previously entered suddenly appears in the table but not necessarily in the correct position.

And even more erratic behaviour in downloads.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


Codes out of order issue:

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


Tests1

  1. created new CV

  2. created a new code and hit the “Save” button
    XHR to create the new code:

    curl 'https://vocabularies-staging.cessda.eu/api/editors/codes' \ -H 'authority: vocabularies-staging.cessda.eu' \ -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"' \ -H 'accept: application/json, text/plain, */*' \ -H 'content-type: application/json' \ -H 'authorization: Bearer ********' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36' \ -H 'sec-ch-ua-platform: "macOS"' \ -H 'origin: https://vocabularies-staging.cessda.eu' \ -H 'sec-fetch-site: same-origin' \ -H 'sec-fetch-mode: cors' \ -H 'sec-fetch-dest: empty' \ -H 'referer: https://vocabularies-staging.cessda.eu/editor/vocabulary/test_cv3' \ -H 'accept-language: en-US,en;q=0.9' \ -H 'cookie: ********' \ --data-raw '{"actionType":"CREATE_CODE","versionId":582,"notation":"c1","title":"c1","definition":"c1","position":0,"insertionRefConceptId":null,"relPosToRefConcept":1,"changeType":"Code added","changeDesc":"c1"}' \ --compressed

    payload:

    { "actionType": "CREATE_CODE", "versionId": 582, "notation": "c1", "title": "c1", "definition": "c1", "position": 0, "insertionRefConceptId": null, "relPosToRefConcept": 1, "changeType": "Code added", "changeDesc": "c1" }

    response:

    {"id":14631,"notation":"c1","title":"c1","definition":"c1","versionId":582,"position":0}

  3. the new code didn’t appear in the list of refreshed CV codes. the XHR request returned a list of codes, where the new code was missing. clearing browser cache didn’t help. cache at the server side?
    XHR request to get the latest state of the CV after saving the code “c1”:

    curl 'https://vocabularies-staging.cessda.eu/api/vocabularies/test_cv3/latest' \ -H 'authority: vocabularies-staging.cessda.eu' \ -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"' \ -H 'accept: application/json, text/plain, */*' \ -H 'authorization: Bearer ********' \ -H 'sec-ch-ua-mobile: ?0' \ -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36' \ -H 'sec-ch-ua-platform: "macOS"' \ -H 'sec-fetch-site: same-origin' \ -H 'sec-fetch-mode: cors' \ -H 'sec-fetch-dest: empty' \ -H 'referer: https://vocabularies-staging.cessda.eu/editor/vocabulary/test_cv3' \ -H 'accept-language: en-US,en;q=0.9' \ -H 'cookie: ********' \ --compressed

    response:

    { "id": 91, "status": "DRAFT", "notation": "test_cv3", "versionNumber": "1.0", "archived": false, "withdrawn": false, "discoverable": true, "sourceLanguage": "en", "agencyId": 1, "agencyName": "CESSDA", "agencyLogo": "cessda.png", "agencyLink": "https://www.cessda.eu/", "codes": [], "versions": [ { "id": 582, "status": "DRAFT", "itemType": "SL", "language": "en", "creationDate": "2022-02-03", "number": "1.0", "title": "test_cv3", "definition": "test_cv3", "notation": "test_cv3", "creator": 107, "vocabularyId": 91, "concepts": [], "comments": [], "versionHistories": [] } ], "versionEn": "1.0", "titleEn": "test_cv3", "definitionEn": "test_cv3" }

→ i suspect caching of concepts

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


If you can find a way to simplify giving order to the codes, that would be very good.

Currently the system works so that the user enters into code value the code (e.g. child 2) and then when they choose to ‘insert as child’, the system adds the hierarchy to the code (code6.child2). If it makes things easier and is not difficult to code, the system can be changed so that instead:

But not being technical, not sure if this would of any help to remove the current difficulties.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


I’m still trying to figure out the cause of the problem. This issue is a tough one. My latest findings are that it is caused by caching, because after I save the new code, the system returns old list without the new code in it, while the new code is saved in the DB, because after some time, it appears in the list.

Besides that, I found a problem that the position of the new code is computed at the client side, which may lead to having two different codes with the same position in the list. It happens when someone else is editing the same CV simultaneously. This led also to unexpected code order. This is fixed - the position of the new code is now computed at the server side. Instead of the absolute position, the client sends along with the new code the ID of the selected code in the list and relative placement (0 - before, 1 - after). If no code is selected, the new code is put at the end of the list. However, there are cases when this fix do not work and all my tests lead to caching.

Regarding your suggestion on changing the way users create code hierarchies, I suggest to create a new feature request for it. I would be happy to implement it, but first of all, I would like to fix this #349 issue with minimum changes to the original code and logic, because otherwise more errors could be induced.

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


If you can fix the the original code and keep the logic, that would be the optimal solution.

I only suggested changing it as an (unwanted) alternative in case you cannot fix the original code. We have no problems with how the system creates hierarchy. If it works, it is quite logical and easy to use for the user.

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


I had to make a new vocbulary draft in the production version today. No problems with creating hierarchy there. The CV only has four terms, of which two are narrower terms, so may not be conclusive information.

Still, is this of any help in figuring out the problem?

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


I created a new vocabulary in staging since I needed a download of the draft for group discussion.

The phenomena commented by Stefan occurred: a new code is added but sometimes the system returns the old list without the new code but the new code appears in the list after a while. This occurred for one code only (the second one) even though I entered four ones altogether.

Moved two codes (one as a child, another as sibling), the system performed these correctly.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


I still suspect caching, but I still didn’t localize it though. There might be different settings for production, staging and dev when deploying the app. When testing the issue locally, there’s never a problem.

I did another tests today, to check, whether it is at the client side. I’ve replicated the original XHR request by which the client reads the latest CV data from the server and executed it 10 times in a loop:

for i in `seq 10`; { curl 'https://vocabularies-staging.cessda.eu/api/vocabularies/test_cv3/latest' \
  -H 'authority: vocabularies-staging.cessda.eu' \
  -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"' \
  -H 'accept: application/json, text/plain, */*' \
  -H 'authorization: Bearer ********' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-site: same-origin' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-dest: empty' \
  -H 'referer: https://vocabularies-staging.cessda.eu/editor/vocabulary/test_cv3?tab=export' \
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cookie: ********' \
  --compressed | json_pp; } > latest.log
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1753      0 --:--:-- --:--:-- --:--:--  1753
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1638      0 --:--:-- --:--:-- --:--:--  1638
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1558      0 --:--:-- --:--:-- --:--:--  1558
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1798      0 --:--:-- --:--:-- --:--:--  1789
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1817      0 --:--:-- --:--:-- --:--:--  1817
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1936      0 --:--:-- --:--:-- --:--:--  1946
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1551      0 --:--:-- --:--:-- --:--:--  1551
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1872      0 --:--:-- --:--:-- --:--:--  1863
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1593      0 --:--:-- --:--:-- --:--:--  1593
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1946      0 --:--:-- --:--:-- --:--:--  1946

The results were weird, concepts appeared and disappeared at random. At the time of calling the XHR request, there were 4 concepts in the CV (c1, c2, c3, and c4):

{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}

Then I repeated the same test, but I added following headers to the XHR request in order to disable caching both at the client (pragma: no-cache) and server side (cache-control: no-cache):

-H 'pragma: no-cache' \                                                           
-H 'cache-control: no-cache' \  

Requests:

for i in `seq 10`; { curl 'https://vocabularies-staging.cessda.eu/api/vocabularies/test_cv3/latest' \
  -H 'authority: vocabularies-staging.cessda.eu' \
  -H 'pragma: no-cache' \                                                           
  -H 'cache-control: no-cache' \                  
  -H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"' \                                                                                                                                     
  -H 'accept: application/json, text/plain, */*' \
  -H 'authorization: Bearer ********' \
  -H 'sec-ch-ua-mobile: ?0' \       
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-site: same-origin' \
  -H 'sec-fetch-mode: cors' \                                                                 
  -H 'sec-fetch-dest: empty' \          
  -H 'referer: https://vocabularies-staging.cessda.eu/editor/vocabulary/test_cv3' \                                                                                                             
  -H 'accept-language: en-US,en;q=0.9' \
  -H 'cookie: ********' \
  --compressed | json_pp } > latest-no-cache.log
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1863      0 --:--:-- --:--:-- --:--:--  1863
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1772      0 --:--:-- --:--:-- --:--:--  1772
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1890      0 --:--:-- --:--:-- --:--:--  1890
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1975      0 --:--:-- --:--:-- --:--:--  1965
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1702      0 --:--:-- --:--:-- --:--:--  1702
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1669      0 --:--:-- --:--:-- --:--:--  1669
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1638      0 --:--:-- --:--:-- --:--:--  1638
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   349    0   349    0     0   1745      0 --:--:-- --:--:-- --:--:--  1736
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1965      0 --:--:-- --:--:-- --:--:--  1965
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   397    0   397    0     0   1872      0 --:--:-- --:--:-- --:--:--  1872

Results:

{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}
{
   "agencyId" : 1,
   "agencyLink" : "https://www.cessda.eu/",
   "agencyLogo" : "cessda.png",
   "agencyName" : "CESSDA",
   "archived" : false,
   "codes" : [],
   "definitionEn" : "test_cv3",
   "discoverable" : true,
   "id" : 91,
   "notation" : "test_cv3",
   "sourceLanguage" : "en",
   "status" : "DRAFT",
   "titleEn" : "test_cv3",
   "versionEn" : "1.0",
   "versionNumber" : "1.0",
   "versions" : [
      {
         "comments" : [],
         "concepts" : [
            {
               "definition" : "c1",
               "id" : 14631,
               "notation" : "c1",
               "position" : 0,
               "title" : "c1",
               "versionId" : 582
            },
            {
               "definition" : "d2",
               "id" : 14636,
               "notation" : "c2",
               "position" : 1,
               "title" : "t2",
               "versionId" : 582
            },
            {
               "definition" : "d3",
               "id" : 14637,
               "notation" : "c3",
               "position" : 2,
               "title" : "t3",
               "versionId" : 582
            },
            {
               "definition" : "d4",
               "id" : 14638,
               "notation" : "c4",
               "position" : 3,
               "title" : "t4",
               "versionId" : 582
            }
         ],
         "creationDate" : "2022-02-03",
         "creator" : 107,
         "definition" : "test_cv3",
         "id" : 582,
         "itemType" : "SL",
         "language" : "en",
         "notation" : "test_cv3",
         "number" : "1.0",
         "status" : "DRAFT",
         "title" : "test_cv3",
         "versionHistories" : [],
         "vocabularyId" : 91
      }
   ],
   "withdrawn" : false
}

I’ll check older issues related to caching (e.g., #307, #300), whether there’s something helpful for this issue. Also, inspect concept caching here, and here.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


Trying to temporarily disable second level cache for concepts here.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


I’ve disabled the L2 cache for concepts in Version.java and did the tests again. This time with success. I’ve tested the behavior in staging (test_CV_349). Disabling L2 cache solved the problems with:

However, I’m not sure, how this change affects the performance, when loading concepts. Maybe a different CacheConcurrencyStrategy settings would work as well with slightly better performance (e.g., TRANSACTIONAL), but I do not have experience with it.

Final notes

I consider this issue as resolved.

cessda-bitbucket-importer commented 2 years ago

Original comment by Taina Jääskeläinen.


Added new codes to TestCV, moved some to be child or child of a child, and published. Code ordering worked correctly.

@Stifo what comments did you mean by “L2 caching settings are left for comments”? Comments entered by users?

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


I mean the commented code at line 144 (the first bullet) and comments entered by users in the editor tab - top right “Comments“ button (the second bullet). The same caching mechanism as it was making problems for codes is applied on the CV comments.

cessda-bitbucket-importer commented 2 years ago

Original comment by Stefan Dlugolinsky (GitHub: Stifo).


@‌TainaFSD regarding the comments and caching, i did some tests in this CV and there were no problems found.