Skip to content

Conversation

@vchunikhin
Copy link
Contributor

fixes #23458

@eantyshev
@olehborysevych


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI.

- `SDK_CONFIG` - is the sdk configuration file path, e.g. default example for corresponding sdk. It will be saved to cloud datastore during application startup (default value = `../sdks.yaml`)
- `DATASTORE_EMULATOR_HOST` - is the datastore emulator address. If it is given in the environment, the application will connect to the datastore emulator.
- `PROPERTY_PATH` - is the application properties path (default value = `.`)
- `CACHE_REQUEST_TIMEOUT` - is the timeout to request data from cache (default value = `30 sec`)
Copy link
Contributor

Choose a reason for hiding this comment

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

It should not be longer than HTTP timeout, we need to check these values on startup

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense, but there is no timeout for requests to retrieve data about precompiled objects. We have timeout only for code processing when a pipeline is created

if err != nil {
logger.Errorf("error during getting the sdk catalog from the cache, err: %s", err.Error())
sdks, err = cp.db.GetSDKs(ctx)
func (cp *CacheComponent) GetSdkCatalogFromCacheOrDatastore(ctx context.Context, cacheRequestTimeout time.Duration) ([]*entity.SDKEntity, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's make timeout a parameter of a CacheComponent, what you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not flexible to configure this parameter this way, i'd like to stay it as an env variable

sdksCh := make(chan []*entity.SDKEntity, 1)
errCh := make(chan error, 1)
go func() {
sdks, err := cp.cache.GetSdkCatalog(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

let's just do cache request with a reduced timeout:

ctx = context.WithTimeout(ctx, CACHE_TO)

no need for goroutines here

return cat, nil
case e := <-errCh:
logger.Errorf("error during getting the catalog from the cache, err: %s", e.Error())
return cp.getCatalog(ctx, cacheRequestTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

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

timeout is a part of a context
https://pkg.go.dev/context#WithDeadline

examples_ids_before_updating = self._get_all_examples(sdk)

# loop through every example to save them to the Cloud Datastore
with self._datastore_client.transaction():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the transaction here because it caused the error related to datastore restriction during deleting an entity group.

Error:

google.api_core.exceptions.InvalidArgument: 400 operating on too many entity groups in a single transaction.

Doc:

https://cloud.google.com/datastore/docs/concepts/structuring_for_strong_consistency#entity_group_limitations_on_transactions

@vchunikhin
Copy link
Contributor Author

R: @pabloem

@vchunikhin vchunikhin marked this pull request as ready for review October 5, 2022 09:22
@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control

@pabloem
Copy link
Member

pabloem commented Oct 31, 2022

lgtm

@pabloem pabloem merged commit 9f33da1 into apache:master Oct 31, 2022
ruslan-ikhsan pushed a commit to akvelon/beam that referenced this pull request Nov 11, 2022
…fault tolerance (apache#23461)

* [Playground] [Backend] updated cache component to handle precompiled object requests correctly

* [Playground] [Backend] added context with timeout instead of goroutine

* [Playground] [Backend] edited cache request timeout variable

* [Playground] [Backend] refactoring after review

* [Playground] [Backend] changed default value in readme

* [Playground] [Backend] removed transaction for ci cd datastore client
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.

[Playground][Task]: Update playground cache component to increase fault tolerance

3 participants