palashc commented on code in PR #1955:
URL: https://github.com/apache/phoenix/pull/1955#discussion_r1723815604
##########
phoenix-core-client/src/main/java/org/apache/phoenix/schema/MetaDataClient.java:
##########
@@ -785,19 +785,37 @@ private boolean avoidRpcToGetTable(boolean
alwaysHitServer, Long resolvedTimesta
final long effectiveUpdateCacheFreq;
final String ucfInfoForLogging; // Only used for logging purposes
+ boolean overrideUcfToDefault = false;
+ if (table.getType() == INDEX) {
+ overrideUcfToDefault =
+
PIndexState.PENDING_DISABLE.equals(table.getIndexState()) ||
+ !IndexMaintainer.sendIndexMaintainer(table);
+ }
+ if (!overrideUcfToDefault && !table.getIndexes().isEmpty()) {
+ List<PTable> indexes = table.getIndexes();
+ List<PTable> maintainedIndexes =
+
Lists.newArrayList(IndexMaintainer.maintainedIndexes(indexes.iterator()));
+ // The maintainedIndexes contain only the indexes that are
used by clients
+ // while generating the mutations. If all the indexes are
usable by clients,
+ // we don't need to override UPDATE_CACHE_FREQUENCY. However,
if any index is
+ // not in usable state by the client mutations, we should
override
+ // UPDATE_CACHE_FREQUENCY to default value so that we make
getTable() RPC calls
+ // until all index states change to ACTIVE, BUILDING or other
usable states.
+ overrideUcfToDefault = indexes.size() !=
maintainedIndexes.size();
+ }
+
// What if the table is created with UPDATE_CACHE_FREQUENCY
explicitly set to ALWAYS?
// i.e. explicitly set to 0. We should ideally be checking for
something like
// hasUpdateCacheFrequency().
//always fetch an Index in PENDING_DISABLE state to retrieve
server timestamp
//QueryOptimizer needs that to decide whether the index can be used
- if (PIndexState.PENDING_DISABLE.equals(table.getIndexState())) {
+ if (overrideUcfToDefault) {
Review Comment:
@virajjasani Default today is ALWAYS so this would work but what if default
is something else? Should we explicitly override to ALWAYS?
This is why I had added a separate config for
`DEFAULT_UPDATE_CACHE_FREQUENCY_FOR_PENDING_DISABLED_INDEX` and set that to
ALWAYS.
--
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]