Skip to content

Commit eed157b

Browse files
haoxu07Hao Xu
andauthored
[server] Extend retry for new superset schema fetching. (#897)
Previous when user updates a new value schema to the AAWC store, the ongoing ingestion will get acknowledged by ZK store to refresh the schema. Previous retry for fetching the new schema from zk is 3 times with a fixed 100ms, which is very short. Without fetching new schema, the store ingestion could fail. For a real-prod system, usually server need to wait for 3~5 seconds to fetch this schema after new schema registered. Here we use exponential back off retry. Co-authored-by: Hao Xu <[email protected]>
1 parent c769e89 commit eed157b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

internal/venice-common/src/main/java/com/linkedin/venice/helix/HelixReadOnlySchemaRepository.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ SchemaEntry forceRefreshSupersetSchemaWithRetry(String storeName) {
163163
Store store = getStoreRepository().getStore(storeName);
164164
int supersetSchemaId = store.getLatestSuperSetValueSchemaId();
165165
AtomicReference<SchemaEntry> supersetSchemaEntry = new AtomicReference<>();
166-
RetryUtils.executeWithMaxAttempt(() -> {
166+
long currentTimestamp = System.currentTimeMillis();
167+
List<Class<? extends Throwable>> retriableExceptions =
168+
Collections.singletonList(InvalidVeniceSchemaException.class);
169+
RetryUtils.executeWithMaxAttemptAndExponentialBackoff(() -> {
167170
try {
168171
getSchemaLock().writeLock().lock();
169172
SchemaData schemaData = getSchemaMap().get(storeName);
@@ -176,7 +179,13 @@ SchemaEntry forceRefreshSupersetSchemaWithRetry(String storeName) {
176179
} finally {
177180
getSchemaLock().writeLock().unlock();
178181
}
179-
}, 3, Duration.ofMillis(100), Collections.singletonList(InvalidVeniceSchemaException.class));
182+
}, 10, Duration.ofSeconds(1), Duration.ofMinutes(1), Duration.ofMinutes(5), retriableExceptions);
183+
long timePassed = System.currentTimeMillis() - currentTimestamp;
184+
logger.info(
185+
"Obtain superset schema id: {} for store {} with time in milliseconds: {}.",
186+
supersetSchemaId,
187+
storeName,
188+
timePassed);
180189
return supersetSchemaEntry.get();
181190
}
182191

internal/venice-common/src/test/java/com/linkedin/venice/helix/HelixReadOnlySchemaRepositoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public void testForceRefreshSchemaData() {
135135
// 3 times force refresh still won't get the schema, exception should be thrown.
136136
when(store.getLatestSuperSetValueSchemaId()).thenReturn(2);
137137
Assert.assertThrows(InvalidVeniceSchemaException.class, () -> schemaRepository.getSupersetSchema(storeName));
138-
verify(schemaRepository, times(7)).forceRefreshSchemaData(any(), any());
138+
verify(schemaRepository, times(14)).forceRefreshSchemaData(any(), any());
139139

140140
when(store.getLatestSuperSetValueSchemaId()).thenReturn(SchemaData.INVALID_VALUE_SCHEMA_ID);
141141
Assert.assertNull(schemaRepository.getSupersetSchema(storeName));

0 commit comments

Comments
 (0)