Skip to content

CDM cache warming still fails when cache.achilles.usePersonCount=false (missing cc alias in getBatchConceptRecordCount.sql) #2561

Closed

Description

@DG47

Expected behavior

With cache.achilles.usePersonCount=false, warming the CDM results cache (GET /cdmresults/{sourceKey}/warmCache, the startup/cron warming job) loads record counts from achilles_result_concept_count into cdm_cache, the same way it does with usePersonCount=true.

Actual behavior

The placeholder fix for #2517 (a9720e7) is in, but the batch query still cannot run. getBatchConceptRecordCount.sql uses cc.concept_id in the select list, join and WHERE clause, but never declares the cc alias:

select cc.concept_id, record_count, descendant_record_count
from @resultTableQualifier.achilles_result_concept_count
join @vocabularyTableQualifier.concept c on cc.concept_id = c.concept_id
WHERE cc.concept_id >= @conceptIdentifierMin and cc.concept_id <= @conceptIdentifierMax

The person-count variant (getBatchConceptRecordPersonCount.sql) declares the alias, so only usePersonCount=false is affected. On PostgreSQL the warm job logs:

ERROR:  missing FROM-clause entry for table "cc" at character 153
ERROR o.o.w.cdmresults.service.CDMCacheService - Failed to warm cache ... Exception: PreparedStatementCallback; bad SQL grammar [select cc.concept_id, record_count, descendant_record_count ...

SQL Server reports The multi-part identifier "cc.concept_id" could not be bound. The error is caught and logged in CDMCacheService.warm, so nothing gets cached and no error reaches the user.

There is a second problem on the same path. CDMCacheBatchService.save decides whether a cached concept changed by unboxing all four counts into a long[]. With usePersonCount=false the person counts are null, so re-warming any concept that is already in cdm_cache throws NullPointerException: Cannot invoke "java.lang.Long.longValue()" because the return value of "...CDMCacheEntity.getPersonCount()" is null.

Steps to reproduce behavior

  1. Set cache.achilles.usePersonCount=false (for example, for a results schema whose achilles_result_concept_count table has no person count columns, see person_count not present in ohdsi_results.achilles_result_concept_count in 2.13.0 #2239).
  2. Call GET /WebAPI/cdmresults/{sourceKey}/warmCache (or enable cache warming).
  3. The job logs "Failed to warm cache" with the SQL error above, and cdm_cache stays empty for the source.

Environment: WebAPI master (817bae8) and master-2.15; reproduced against embedded PostgreSQL 15 in the WebAPI test harness, JDK 21.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions