Skip to content
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

Intermittent 404 issues for customers who came from another DB engine #30243

Closed
erickgonzalez opened this issue Oct 3, 2024 · 2 comments · Fixed by #30244
Closed

Intermittent 404 issues for customers who came from another DB engine #30243

erickgonzalez opened this issue Oct 3, 2024 · 2 comments · Fixed by #30244

Comments

@erickgonzalez
Copy link
Contributor

erickgonzalez commented Oct 3, 2024

Parent Issue

#30000

Problem Statement

After getting the new logs, saw that the 404 was coming from the Identifier:

19/09/24 13:54:12:144 UTC] DEBUG business.IdentifierFactoryImpl: 404 Identifier found: Identifier [id=null, assetName=/phn-assets/phn-dynamic-pdfs/en/rif_invest_app_form_4_0_0.pdf, assetType=$$__404__CACHE_MISS__$$, parentPath=null, hostId=552d9ea5-a6c9-4cb2-bb0b-febdef8e35cf, sysPublishDate=null, sysExpireDate=null]

The code we use to get the identifier is the following:

protected Identifier findByURI(final String siteId, final String uri) throws DotDataException {
Identifier identifier = ic.getIdentifier(siteId, uri);
if (identifier != null) {
return check404(identifier);
}
final DotConnect dc = new DotConnect();
final String parentPath = uri.substring(0, uri.lastIndexOf("/") + 1).toLowerCase();
final String assetName = uri.substring(uri.lastIndexOf("/") + 1).toLowerCase();
dc.setSQL("select * from identifier i where i.full_path_lc = ? and host_inode = ?");
dc.addParam((parentPath + assetName).toLowerCase());
dc.addParam(siteId);
List<Identifier> results = null;
results = TransformerLocator.createIdentifierTransformer(dc.loadObjectResults()).asList();
if (results != null && !results.isEmpty()){
identifier = results.get(0);
}
if(identifier==null || !InodeUtils.isSet(identifier.getId())) {
identifier = build404(siteId,uri);
}
ic.addIdentifierToCache(identifier);
return check404(identifier);
}

Looking at the code, this column full_path_lc should be a function, not a column (at least in Postgres); for customers that were migrated from another DB engine, this was kept as a column and wasn't being filled.

Steps to Reproduce

Only Reproducible with customer data.

  1. Start dotcms.
  2. Run the following query against the DB to create the column:
ALTER TABLE identifier
ADD COLUMN full_path_lc varchar(250);
  1. Flush the cache
  2. Add a new file
  3. Hit it from the Resource Link
  4. Get the 404 (this is intermittent)
  5. Run the following API to execute the UT:
curl --location 'http://localhost:8080/api/v1/upgradetask' \--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
    "upgradeTaskClass":"com.dotmarketing.startup.runonce.Task241013RemoveFullPathLcColumnFromIdentifier"
}
  1. Flush the cache
  2. Hit again the asset from the resource link
  3. Should get 200

Acceptance Criteria

Pages and Files should return 200.

Create a UT that does the following:
1- Remove full_path_lc column:

ALTER TABLE identifier
DROP COLUMN full_path_lc;

2- Create the function if it doesn’t exists:

CREATE OR REPLACE FUNCTION full_path_lc(identifier) RETURNS text
    AS ' SELECT CASE WHEN $1.parent_path = ''/System folder'' then ''/'' else LOWER($1.parent_path || $1.asset_name) end; '
LANGUAGE SQL;

3- Create index (first check if exists):

CREATE UNIQUE INDEX idx_ident_uniq_asset_name on identifier (full_path_lc(identifier),host_inode);

dotCMS Version

22.03 LTS and 24.04 LTS.

Proposed Objective

Customer Success

Proposed Priority

Priority 1 - Show Stopper

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

https://helpdesk.dotcms.com/a/tickets/27067

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

@erickgonzalez erickgonzalez self-assigned this Oct 3, 2024
@erickgonzalez erickgonzalez moved this from New to Current Sprint Backlog in dotCMS - Product Planning Oct 3, 2024
@erickgonzalez erickgonzalez moved this from Current Sprint Backlog to In Progress in dotCMS - Product Planning Oct 3, 2024
@erickgonzalez erickgonzalez added the LTS: Next Patch Shortlisted of issues that will be included in the upcoming LTS patch label Oct 4, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 8, 2024
During the migration of customers from another database engine to
Postgres, a column was inadvertently left behind. This oversight has
resulted in 404 errors because in Postgres, the column is interpreted as
a function, not a column.

Added a note in the MainSuite2a since it lasts twice than other suites.
@github-project-automation github-project-automation bot moved this from In Review to Internal QA in dotCMS - Product Planning Oct 8, 2024
erickgonzalez added a commit that referenced this issue Oct 23, 2024
erickgonzalez added a commit that referenced this issue Oct 23, 2024
@erickgonzalez erickgonzalez added Release : 23.10.24 v18 Included in LTS patch release 23.10.24 v18 Release : 24.04.24 v10 Included in LTS patch release 24.04.24 v10 labels Oct 25, 2024
@gortiz-dotcms
Copy link
Contributor

Passed internal QA

After flushing cache, didn't get any 404 when hitting the recent added file from Resource Link

Screenshot

@erickgonzalez erickgonzalez removed the LTS: Next Patch Shortlisted of issues that will be included in the upcoming LTS patch label Oct 28, 2024
@bryanboza
Copy link
Contributor

Fixed, unable to reproduce using the provided steps, now I'm able to open the file without problems

spbolton pushed a commit that referenced this issue Nov 11, 2024
During the migration of customers from another database engine to
Postgres, a column was inadvertently left behind. This oversight has
resulted in 404 errors because in Postgres, the column is interpreted as
a function, not a column.

Added a note in the MainSuite2a since it lasts twice than other suites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants