Akshat-Jain opened a new pull request, #16307:
URL: https://github.com/apache/druid/pull/16307

   ### Description
   
   Currently, when we add a lookup with the lookupExtractorFactory's type as 
`cachedNamespace` configured with a JDBC source, we run into NPE while loading 
the lookup if the configured JDBC source table has no rows.
   
   Sample NPE logs:
   ```java
   2024-04-17T09:44:32,936 ERROR [NamespaceExtractionCacheManager-0] 
org.apache.druid.server.lookup.namespace.cache.CacheScheduler - Failed to 
update namespace 
[JdbcExtractionNamespace{connectorConfig=DbConnectorConfig{createTables=true, 
connectURI='jdbc:postgresql://localhost:5432/druid', user='druid', 
passwordProvider=org.apache.druid.metadata.DefaultPasswordProvider, 
dbcpProperties=null}, table='pglookuptable1', keyColumn='country_id', 
valueColumn='country_name', tsColumn='timeColumn', filter='null', 
pollPeriod=PT1M, jitterSeconds=0, loadTimeoutSeconds=120, 
maxHeapPercentage=10}] : 
org.apache.druid.server.lookup.namespace.cache.CacheScheduler$EntryImpl@64c4522
   java.lang.NullPointerException: null
        at 
org.apache.druid.server.lookup.namespace.JdbcCacheGenerator.lastUpdates(JdbcCacheGenerator.java:219)
 ~[?:?]
        at 
org.apache.druid.server.lookup.namespace.JdbcCacheGenerator.generateCache(JdbcCacheGenerator.java:72)
 ~[?:?]
        at 
org.apache.druid.server.lookup.namespace.JdbcCacheGenerator.generateCache(JdbcCacheGenerator.java:48)
 ~[?:?]
        at 
org.apache.druid.server.lookup.namespace.cache.CacheScheduler$EntryImpl.tryUpdateCache(CacheScheduler.java:236)
 ~[?:?]
        at 
org.apache.druid.server.lookup.namespace.cache.CacheScheduler$EntryImpl.updateCache(CacheScheduler.java:208)
 ~[?:?]
        at 
java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
 [?:?]
        at 
java.base/java.util.concurrent.FutureTask.runAndReset$$$capture(FutureTask.java:305)
 [?:?]
        at 
java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java) [?:?]
        at 
java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
 [?:?]
        at 
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 [?:?]
        at 
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 [?:?]
        at java.base/java.lang.Thread.run(Thread.java:829) [?:?]
   ```
   
   This PR handles the NPE, and adds a test for validating the corresponding 
flow.
   
   This PR has:
   
   - [x] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to