-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drupal / Gemini File UUID Mismatch #1076
Comments
I may be kicking myself soon... is that media uuid instead of the file? |
Funny thing, it IS a media UUID for the Service File of a completely different object (ent000817-037). |
Actually, it isn't. I thought I found that 498944af-2773-4d4b-9526-9f7a08d326da on another media, but that uuid doesn't match after all. I can't find it in Drupal anywhere. |
@seth-shaw-unlv are you using Islandora Riprap at all? If so, don't discount the possibility that my coding in one or more of the classes at https://github.com/mjordan/islandora_riprap/tree/master/src/Riprap is the culprit ..... it doesn't write to Gemini but if a file is not found in Gemini by Islandora Riprap, we probably should do a sanity check on how it gets UUIDs from the JSON. |
@mjordan I was initially submitting this issue on riprap, and I have submitted the sanity check as a separate issue there, but as I looked into it and double-checked everything (looking in the JSON API output and the database tables) I determined that this is first and foremost a problem with Gemini and Drupal having mismatched UUIDs. |
Cool, let's tackle one issue at a time. |
I mentioned Media because we changed how we index them in Gemini a while ago, like a year or so ago. TL;DR there's weird timing issues, and it's really just the file and the node that get indexed in Gemini, not the Media. And yeah... this is surely just a bug that's been laying in wait until someone uses Islandora 8 enough to find it. So what's different between the two that would make one get indexed properly and another not? They're both files in Fedora, right? It's not like this is because one's on public or not... And maybe is one a derivative and the other an original file? |
That's the thing... there is no difference between them that I am aware of. They are both Original Files saved to the 'fedora://' filesystem. They were added on two different days... perhaps something happened as I was trying to work through Drupal 8 Migrate errors? |
Oh... I just compared the times on each of these database records. For the successful one (which was loaded later) the Gemini record was created about 6 hours after the Drupal record (give or take since I'm not sure if any time-zones are being accounted for there). I presume the lag is due to a Camel message queue wait. Or should the Gemini update be more instantaneous with Flysystem? I haven't checked to be certain what the data flows look like. Anyway, the unsuccessful one shows a Gemini create time nearly two full days before the Drupal create time, which implies to me that I had done a Migration rollback and migrated it again. I presume the roll back would have wiped the Drupal file record but may not have triggered a Gemini Delete. So, when I migrated the file again it had the same path as before but a new uuid, which would explain why I can't find the uuid recorded in Gemini in Drupal anywhere. Does that hypothesis make sense? Anyone want to test a migrate, rollback, and re-migrate to see what happens to Drupal v. Gemini? |
@seth-shaw-unlv In theory, it would trigger the events. Whether or not they were processed or when on the other hand, is a totally different scenario. Most likely things would fall apart somewhere downstream. I can certainly try and replicate. And it might be worthwhile to investigate how we could rebuild a Gemini index. |
@dannylamb Well, strike that theory. Using a relatively fresh box (built 9 days ago): I migrated a file (Gemini and Drupal's uuids matched), performed a roll-back (confirmed they were gone from both Drupal and Gemini), and ran the migration again (the file had a new uuid, but Drupal and Gemini had the new uuid). So, yeah, 🤷♂️ . P.S. For some reason Gemini is recording date/times in Central time despite my being in Pacific time while Drupal is recording the epoc value correctly. |
Well, good to know it works, but that doesn't help us sort out what happened to you. I imagine throughout the course of development that it may be common to make some duds, but still. So do those UUIDs exist at all in Drupal? |
I haven't been able to find them. I checked node uuids, file uuids, and media uuids. I didn't see them anywhere. Another point of reference, I threw some queries at the database:
That means ~82% of my Drupal File uuids don't match Gemini. I'm going to try using that list of uuids and uris to create a mass Gemini update script to get the correct uuids in place. It feels heavy handed, but I want my riprap running... |
So, @dannylamb, to further confirm the Gemini uuid isn't in Drupal I exported the whole Drupal database and grep-ed for the uuids. I can confirm that the working item is in both and, for the non-working one, the Drupal uuid is only in Drupal and the Gemini uuid is only in Gemini. Between the dates and the non-matching uuids, I really feel like Drupal created new records with new uuids but Gemini failed to either delete or update. I just don't know why. |
@dannylamb, I just checked my gemini log. (I feel silly for not looking at it earlier.) For ent000725-013 (the failed one) the Gemini UUID (498944af-2773-4d4b-9526-9f7a08d326da) shows up as a successful PUT on 2019-02-19:
But it never shows up in the log again. The Drupal UUID for the same item (de77f71f-6321-4cb7-900a-080ffb219cbf) pops up in the log two days later:
It returned a 204. At this point Gemini still has the old UUID for this item and has no record of the Drupal UUID it just received in the PUT command. This is evidenced by further gemini log messages where we look for the Drupal UUID and receive 404 responses:
There are several similar requests for the Drupal UUID, each receiving the same response: 404. |
Addendum to the Migrate possibility, I also attempted a So, I can't find fault with the Drupal API in my small tests on this account. I wonder if this is all a symptom of #978; camel crashed, never processed the Gemini delete, and the 204 wasn't really a success but a failure due to an entry already using the fedora or drupal uri. @dannylamb, does Gemini have a database unique constraint on any field other than the UUID that may have resulted in this happening? |
Ah hah! Gemini has a unique key on the fedora/drupal uri hashes:
Since both the Drupal and Fedora URIs shouldn't have changed from one entry to the other the hashes wouldn't have either. The log doesn't show a delete for the old record so the database constraint would have refused the new one. However, the 204 response (SUCCESS, NO CONTENT) doesn't accurately reflect the new record's failure. |
@seth-shaw-unlv that is some pretty sweet trouble-shootin' 😃 |
@seth-shaw-unlv Looking at the code, it should:tm: update if the record already exists. I'll have to manually send some requests to confirm this behaviour. |
@seth-shaw-unlv Ok, so after digging deeper (and finding out we don't even have a logger in the controller...) I've managed to step through all this and sort out what's going on. Turns out it's not blowing up because Doctrine considers the update query containing the exact same information to be ok and doesn't throw any exceptions. Hence 204, which is a success as in "Nothing changed... here's no content". Which isn't exactly "Success, something was changed... here's no content". I can't really think of a status code that would express that off the top of my head. Maybe it could be 200 but with a message? |
@dannylamb so when this SQL command occurs does anything change in Gemini? |
|
@whikloj It makes the update query, which is successfully applied, but it just overwrites it with the exact same data. So it's successful in technicality.
|
So looking back here I am confused. @dannylamb is indicating that the service is simply overwriting the existing DB record with an exact copy. Whereas @seth-shaw-unlv seems to be saying that the second insert/update has the same Drupal and Fedora URI but a different UUID. So it is not an exact copy. I think we need consensus on which it is before we can move forward here. |
Also @dannylamb has somehow commented in the future 👻 So his is always last. |
@whikloj is right. It isn't creating an exact copy because the UUID is different. Two separate POSTs, both have the same Drupal and Fedora URIs but with different UUIDs. The second POST isn't saving the new UUID so it shouldn't return success. |
Perhaps a 409 (Conflict)? |
How in the world did I time travel? Github best unlock its secrets to me. I have children, dangit, and need more time for everything! |
Anyhow, sorry I misunderstood the situation @seth-shaw-unlv. Let me test again and see if it throws an error in that instance, too. Because if it does blow up I'd expect to get a 500 based on how the code is now. |
@seth-shaw-unlv Confirmed.
I'm on board. 409 FTW. |
So this seems to be the issue, but I am unclear why we can update the URLs? Other than using this to determine if we are creating (201 Created) or updating (204 No Content) do we need this? |
Is this still a thing? |
It is still a thing, but it is an edgecase that only shows up when something else broke. So, yeah, a bug, but a minor one. |
Given that we've ditched Gemini due to reasons just like this, I'm closing the issue. |
While testing riprap I discovered several of my Media aren't getting picked up by check_fixity because the uuid being reported by the JSON API (sourced from the Drupal file_managed.uuid field) doesn't match the uuid stored in Gemini for that file. However, it is inconsistent. Some do match while many don't.
For example, (after adding some print statements to riprap's PluginFetchResourceListFromDrupal.php) one of my successful items reports:
Indeed, the Gemini db does have the correct uuid for this item:
Compared to Drupal for the corresponding file:
However, one of my unsuccessful ones displays:
'fedora_url' is blank because
$fedora_url = $this->getFedoraUrl($media['field_media_file'][0]['target_uuid']);
, which queries Gemini using the uuid, returned false. Indeed, the Gemini database has a different UUID for this item: ('de77f71f-6321-4cb7-900a-080ffb219cbf' in Drupal, '498944af-2773-4d4b-9526-9f7a08d326da' in Gemini)Compared to Drupal:
It is not clear to me why some uuids would be correctly recorded in Gemini, while others aren't. Any theories about the cause or strategies for fixing the discrepancies are welcomed.
The text was updated successfully, but these errors were encountered: