Page MenuHomePhabricator

Call to a member function updateDatasourceTokens() on null at PhabricatorProjectFulltextEngine.php:20 (due to DB corruption)
Closed, ResolvedPublicBUG REPORT

Description

Some more logspam but no idea how to reproduce or even call that source code file:

[2023-09-03 14:42:29] EXCEPTION: (Error) Call to a member function updateDatasourceTokens() on null at [<phorge>/src/applications/project/search/PhabricatorProjectFulltextEngine.php:20]
arcanist(), ava(), phorge(), translations(), wmf-ext-misc()
  #0 phlog(Error) called at [<phorge>/src/aphront/handler/PhabricatorDefaultRequestExceptionHandler.php:41]
  #1 PhabricatorDefaultRequestExceptionHandler::handleRequestThrowable(AphrontRequest, Error) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:751]
  #2 AphrontApplicationConfiguration::handleThrowable(Error) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:296]
  #3 AphrontApplicationConfiguration::processRequest(AphrontRequest, PhutilDeferredLog, AphrontPHPHTTPSink, MultimeterControl) called at [<phorge>/src/aphront/configuration/AphrontApplicationConfiguration.php:204]
  #4 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phorge>/webroot/index.php:35]

I wonder if this could be vaguely related to T224662

Event Timeline

Aklapper triaged this task as Low priority.
Aklapper changed the subtype of this task from "Task" to "Bug Report".Oct 27 2023, 10:31 AM

I can reproduce “Call to a member function updateDatasourceTokens() on null” reliably by searching all documents for “quarry” (search link). Searching open documents or open tasks works fine.

image.png (376×289 px, 28 KB)

Thanks for finding reproduction steps! <3

I wonder if this could be vaguely related to T224662

It is not. Can still reproduce.

DarkConsole shows that Phab ends up in updateDatasourceTokens() in https://we.phorge.it/source/phorge/browse/master/src/applications/project/storage/PhabricatorProject.php$454 if things do go well:

query	SELECT `project`.* FROM `project` `project`  WHERE (project.id IN (800))   ORDER BY `project`.`name` ASC
query	SELECT * FROM `phabricator_project`.`project` WHERE projectPath IN ('js_H')
query	SELECT * FROM `phabricator_project`.`project_slug` WHERE projectPHID IN ('PHID-PROJ-yh2h2e536o6uq6dvw3bu')
query	SELECT * FROM `project_slug` WHERE projectPHID = 'PHID-PROJ-yh2h2e536o6uq6dvw3bu'
query	START TRANSACTION
query	DELETE FROM `project_datasourcetoken` WHERE projectID = 800
query	INSERT INTO `project_datasourcetoken` (projectID, token) VALUES (800, 'quarry')
query	COMMIT
query	SELECT `project`.* FROM `project` `project`  WHERE (project.id IN (5469))   ORDER BY `project`.`name` ASC 
query	SELECT * FROM `phabricator_project`.`project` WHERE projectPath IN ('.Z2c')

If things go wrong then there is no query call after that last line above. The result of that last query is incorrectly empty thanks to database corruption due to using a broken custom downstream script which we finally removed in T342275: Remove script to convert Phabricator parent project into subproject.

See SELECT * FROM phabricator_project.project WHERE id = 5469 OR id = 800 OR id = 832; for all involved three projects.

Aklapper renamed this task from Call to a member function updateDatasourceTokens() on null at PhabricatorProjectFulltextEngine.php:20 to Call to a member function updateDatasourceTokens() on null at PhabricatorProjectFulltextEngine.php:20 (due to DB corruption).Apr 29 2024, 11:35 AM
Aklapper claimed this task.

This problem was created in T177787#9023514 when using the custom script which got deleted in https://gitlab.wikimedia.org/repos/phabricator/phabricator/-/merge_requests/18/diffs which did not handle updating the projectPath in the phabricator_project.project DB table.

I now ran

UPDATE phabricator_project.project SET projectDepth = 2 WHERE id = 5469 AND projectDepth = 1;
UPDATE phabricator_project.project SET projectPath = "js_H.Z2cmSjR" WHERE id = 5469 AND projectPath = ".Z2cmSjR";

and it is now possible to access https://phabricator.wikimedia.org/project/manage/5469/, and Lucas' steps in T345563#9516966 don't show an error anymore.