-
Notifications
You must be signed in to change notification settings - Fork 298
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
chore: warehouse backend config refactoring #3602
Merged
Merged
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
b1b0c1b
chore: typo
fracasula fbc204f
chore: backend-config manager
fracasula ba0427d
fix: retry
fracasula 1deb4ac
fix: api
fracasula 58f4dfa
fix: admin
fracasula 451348c
chore: updating tests
fracasula 87ff175
chore: removing unused attributes
fracasula f47aaab
chore: bigquery test fix
fracasula 301e17a
chore: linting
fracasula 0bc99d5
chore: moving constructor
fracasula 44aeb08
chore: refactor wh grpc test
fracasula 7b95baa
chore: removing duplicated code in test
fracasula cdd1bc8
chore: cleaning up
fracasula b8d36a0
chore: ssh tunneling and logger
fracasula 8dd4296
chore: removing unused client
fracasula ccf5134
chore: better routine management
fracasula a5e75a2
chore: rename variable
fracasula 7e3d25f
chore: removing TODOs
fracasula 2a30339
chore: more efficient workerIdentifier()
fracasula c70b229
chore: adding TODOs
fracasula d79319d
chore: adding info to backendConfigSubscriber
fracasula 39cd70b
chore: optimizing concurrent code
fracasula 0ad24f7
chore: using logger
fracasula ee7b1e1
chore: initialConfigFetched
fracasula 5c756c7
chore: moving var
fracasula 642dd40
chore: TODO
fracasula b24e638
chore: wrapped db handle
fracasula 077abc3
chore: moving workerChannelMap initialization
fracasula 8f9f564
chore: removing unused field
fracasula 009d557
chore: removing unused variable
fracasula ca754ee
chore: go-kit v0.15.4
fracasula b4305f3
fix: alteredSchemaInAtLeastOneTable data race
fracasula fcd31db
chore: send all warehouses to subscriptions
fracasula 53d0def
chore: formatting
fracasula 99be513
chore: removing unnecessary logic
fracasula 1f0f024
chore: reformat
fracasula 3fc87a8
chore: added test case
achettyiitr fe6d88a
Merge branch 'master' of github.com:rudderlabs/rudder-server into cho…
achettyiitr e3a6c6e
chore: added test case for many subscribers data race
achettyiitr 1c8e8fe
Merge branch 'master' of github.com:rudderlabs/rudder-server into cho…
achettyiitr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,6 @@ func initWarehouse() { | |
Init2() | ||
Init3() | ||
Init4() | ||
Init5() | ||
} | ||
|
||
var _ = Describe("Scheduling", func() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,6 @@ var ( | |
runningMode string | ||
uploadStatusTrackFrequency time.Duration | ||
uploadAllocatorSleep time.Duration | ||
waitForConfig time.Duration | ||
waitForWorkerSleep time.Duration | ||
ShouldForceSetLowerVersion bool | ||
maxParallelJobCreation int | ||
|
@@ -181,7 +180,6 @@ func loadConfig() { | |
runningMode = config.GetString("Warehouse.runningMode", "") | ||
config.RegisterDurationConfigVariable(30, &uploadStatusTrackFrequency, false, time.Minute, []string{"Warehouse.uploadStatusTrackFrequency", "Warehouse.uploadStatusTrackFrequencyInMin"}...) | ||
config.RegisterDurationConfigVariable(5, &uploadAllocatorSleep, false, time.Second, []string{"Warehouse.uploadAllocatorSleep", "Warehouse.uploadAllocatorSleepInS"}...) | ||
config.RegisterDurationConfigVariable(5, &waitForConfig, false, time.Second, []string{"Warehouse.waitForConfig", "Warehouse.waitForConfigInS"}...) | ||
config.RegisterDurationConfigVariable(5, &waitForWorkerSleep, false, time.Second, []string{"Warehouse.waitForWorkerSleep", "Warehouse.waitForWorkerSleepInS"}...) | ||
config.RegisterBoolConfigVariable(true, &ShouldForceSetLowerVersion, false, "SQLMigrator.forceSetLowerVersion") | ||
config.RegisterIntConfigVariable(8, &maxParallelJobCreation, true, 1, "Warehouse.maxParallelJobCreation") | ||
|
@@ -258,6 +256,10 @@ func (wh *HandleT) backendConfigSubscriber(ctx context.Context) { | |
for warehouses := range bcManager.Subscribe(ctx) { | ||
wh.Logger.Info(`Received updated workspace config`) | ||
|
||
warehouses = lo.Filter(warehouses, func(warehouse model.Warehouse, _ int) bool { | ||
return warehouse.Destination.DestinationDefinition.Name == wh.destType | ||
}) | ||
Comment on lines
+258
to
+260
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @achettyiitr we could also do this to save ourselves the next warehouses = lo.Filter(warehouses, func(warehouse model.Warehouse, _ int) bool {
if warehouse.Destination.DestinationDefinition.Name != wh.destType {
return false
}
if warehouseutils.IDResolutionEnabled() &&
slices.Contains(warehouseutils.IdentityEnabledWarehouses, wh.destType) {
wh.setupIdentityTables(ctx, warehouse)
if shouldPopulateHistoricIdentities && warehouse.Destination.Enabled {
// non-blocking populate historic identities
wh.populateHistoricIdentities(ctx, warehouse)
}
}
return true
}) |
||
|
||
wh.configSubscriberLock.Lock() | ||
wh.warehouses = warehouses | ||
if wh.workspaceBySourceIDs == nil { | ||
|
@@ -1453,11 +1455,13 @@ func Start(ctx context.Context, app app.App) error { | |
bcManager.Start(ctx) | ||
}) | ||
|
||
RegisterAdmin(bcManager, pkgLogger) | ||
|
||
runningMode := config.GetString("Warehouse.runningMode", "") | ||
if runningMode == DegradedMode { | ||
pkgLogger.Infof("WH: Running warehouse service in degraded mode...") | ||
if isMaster() { | ||
err := InitWarehouseAPI(dbHandle, pkgLogger.Child("upload_api")) | ||
err := InitWarehouseAPI(dbHandle, bcManager, pkgLogger.Child("upload_api")) | ||
if err != nil { | ||
pkgLogger.Errorf("WH: Failed to start warehouse api: %v", err) | ||
return err | ||
|
@@ -1554,7 +1558,7 @@ func Start(ctx context.Context, app app.App) error { | |
return nil | ||
})) | ||
|
||
err := InitWarehouseAPI(dbHandle, pkgLogger.Child("upload_api")) | ||
err := InitWarehouseAPI(dbHandle, bcManager, pkgLogger.Child("upload_api")) | ||
if err != nil { | ||
pkgLogger.Errorf("WH: Failed to start warehouse api: %v", err) | ||
return err | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,6 @@ func initWarehouse() { | |
Init2() | ||
Init3() | ||
Init4() | ||
Init5() | ||
validations.Init() | ||
misc.Init() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
You are viewing a condensed version of this merge commit. You can view the full changes here.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@achettyiitr this version was better, now we're holding the lock for the duration of the whole subscribe. I think we should put this code back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason, we are adding this is because there is a race condition happening if we are not subscribers and we get backed config. The subscriber will not get anything until the next time we get the backend config changes
So, during the subscription also, we are sending the last copy of the data.