Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DVC] Add RequestBasedMetaRepository to enable metadata retrieval directly from server #1467

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pthirun
Copy link
Contributor

@pthirun pthirun commented Jan 23, 2025

[DVC] Add RequestBasedMetaRepository to enable metadata retrieval directly from server

This PR introduces the use of the /store_properties/{store_name} endpoint to retrieve and cache store metadata for the DaVinci client. The endpoint was implemented in the Venice Server in this PR: #1374.

The RequestBasedMetaRepository leverages this endpoint to maintain a cache of Store and SchemaData objects for requested stores. The cache is refreshed by the NativeMetadataRepository, which this new class extends.

By default, this feature is disabled in the ClientConfig passed to the NativeMetadataRepository. The default configuration preserves the current behavior of using the ThinClientMetaStoreBasedRepository. The relevant configuration field is ClientConfig.useRequestBasedMetaRepository. For more details, see NativeMetadataRepository.getInstance.

How was this PR tested?

Unit and Integration test included in PR.

Does this PR introduce any user-facing changes?

  • No. You can skip the rest of this section.
  • Yes. Make sure to explain your proposed changes and call out the behavior change.

NOTE: behavior will not change by default, feature flag in ClientConfig must be turned on.

@pthirun pthirun requested a review from xunyin8 January 23, 2025 00:46
@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch 2 times, most recently from cfa6434 to 80f0745 Compare January 23, 2025 22:29
Copy link
Contributor

@xunyin8 xunyin8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, thanks for the refactoring. Just some minor comments and also looks like test coverage is not passing.

@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch 16 times, most recently from 00fdc3a to 50d3ef2 Compare February 6, 2025 21:25
@pthirun pthirun self-assigned this Feb 6, 2025
@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch from 50d3ef2 to de203f4 Compare February 6, 2025 22:21
Copy link
Contributor

@xunyin8 xunyin8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes and unit tests, I think we are a bit lacking on the integration tests. See comments below.

@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch from de203f4 to 277b16c Compare February 6, 2025 23:37
@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch 3 times, most recently from 21595b2 to 521c4b3 Compare February 12, 2025 21:38
@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch 8 times, most recently from 06c75e5 to 6cc8286 Compare February 13, 2025 00:56
File dataDir = getPushJobAvroFileDirectory(storeName);
String dataDirPath = "file:" + dataDir.getAbsolutePath();

if (!controllerClients.containsKey(storeName)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the ContollerClients map to keep track of created stores. I think this is appropriate since the IntegrationTestPushUtils.createStoreForJob method returns a controllerClient, even though we only need one instance of the ControllerClient to create new value schemas.

Digging into the createStoreForJob method, it does look like the D2ControllerClientFactory caches the controllerClient by (clusterName, d2ServiceName,d2ZkHost). So this should result in all of the clients in this map to point to the same client instance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically we share the cluster environment across tests because a cluster is expensive and the things we are testing for generally don't break the cluster environment. However, I'd recommend you stay away from sharing stores across different tests. Stores are cheaper to create and if certain test fail it might leave the store in a bad state where other tests will also fail. This will lead to scenarios where you see 10 tests fail but really only 1 test failed and caused the store to be in a bad state. The order of test execution might also have side effects on the result of the test (making it flaky). Can we refactor this class so we are not sharing stores across tests?

@@ -70,7 +62,7 @@ public abstract class NativeMetadataRepository
private final Map<String, StoreConfig> storeConfigMap = new VeniceConcurrentHashMap<>();
// Local cache for key/value schemas. SchemaData supports one key schema per store only, which may need to be changed
// for key schema evolvability.
private final Map<String, SchemaData> schemaMap = new VeniceConcurrentHashMap<>();
protected Map<String, SchemaData> schemaMap = new VeniceConcurrentHashMap<>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the final here so we may initialize this map in unit test mocking.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you point me to the unit test you are talking about? I don't see why this is necessary to achieve unit test mocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RequestBasedMetaRepositoryTest.java and ThinClientMetaStoreBasedRepositoryTest.java.
In the unit tests, I am partially mocking the client object by using Mockito's thenCallRealMethod.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mocked clients do not seem to run any initialization on private final class variables, so these maps need to be initialized by the test.

@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch from 6cc8286 to ea4f353 Compare February 13, 2025 01:53
Copy link
Contributor

@xunyin8 xunyin8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good, just one minor concern about Thread.sleep usage in test and exposing some class field for unit test mocking.

assertFalse(resp.isError());
assertFalse(parentControllerClient.emptyPush(storeName, "test-push-job", 100).isError());
try {
Thread.sleep(10000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already using TestUtils.waitForNonDeterministicPushCompletion. We should avoid using Thread.sleep and why do we even need it here?.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests were not passing early on due to the stores not being ready fast enough, however removing it now and testing locally seems to work. I pushed changes to remove this sleep, waiting on CI to finish.

@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch 4 times, most recently from b66105c to 445c790 Compare February 19, 2025 03:27
@pthirun pthirun force-pushed the feature/dvc-request-based-metadata-01-22-2025 branch from 445c790 to c9b0f16 Compare February 19, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants