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

Serialize chain elements #583

Merged
merged 12 commits into from
Dec 1, 2020

Conversation

Bolodya1997
Copy link

Issue

Request, Close events for the same Connection.ID should be processed serially in the whole network service chain. At the moment, there is no such convention and so every new chain element should use some internal synchronization to make such thing inside of it. It leads to the multiple times serializing already serialized events but we still need to make such things for all newly created chain elements because there is no guarantee that someone would do this instead of us.

Solution

Create single chain element that is responsive for all per-connection events serializing.

@Bolodya1997 Bolodya1997 marked this pull request as draft November 16, 2020 06:48
@Bolodya1997 Bolodya1997 marked this pull request as ready for review November 16, 2020 06:53
@Bolodya1997 Bolodya1997 force-pushed the serialize branch 2 times, most recently from 570d15d to b19c7ef Compare November 16, 2020 12:34
@denis-tingaikin denis-tingaikin requested a review from xzfc November 16, 2020 12:56
@edwarnicke
Copy link
Member

Question: Why are you serializing Close and Request separately for a given Connection Id? Its not what I expected, and you usually have good reasons for such things :)

@edwarnicke
Copy link
Member

Also, you may find this potentially useful:

#590

@Bolodya1997
Copy link
Author

Question: Why are you serializing Close and Request separately for a given Connection Id? Its not what I expected, and you usually have good reasons for such things :)

They are not being serialized separately - there are 2 different wrappers for the same executor, because after the Close event we should mark executor as closed and we can't access executor.state from some chain element other than serialize.

@edwarnicke
Copy link
Member

Question: Why are you serializing Close and Request separately for a given Connection Id? Its not what I expected, and you usually have good reasons for such things :)

They are not being serialized separately - there are 2 different wrappers for the same executor, because after the Close event we should mark executor as closed and we can't access executor.state from some chain element other than serialize.

Got it :)

@denis-tingaikin
Copy link
Member

@xzfc Could you take a look at this PR? It seems to me this can be usful for refresh

@Bolodya1997 Bolodya1997 force-pushed the serialize branch 2 times, most recently from 09b73a0 to 76ac337 Compare November 24, 2020 08:15
Copy link
Member

@denis-tingaikin denis-tingaikin left a comment

Choose a reason for hiding this comment

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

This version looks better. Added comments.

pkg/tools/multiexecutor/multi_executor.go Outdated Show resolved Hide resolved
pkg/networkservice/common/serialize/executor_func.go Outdated Show resolved Hide resolved
pkg/networkservice/common/serialize/context.go Outdated Show resolved Hide resolved
pkg/networkservice/common/serialize/context.go Outdated Show resolved Hide resolved
pkg/tools/multiexecutor/multi_executor_test.go Outdated Show resolved Hide resolved
@@ -141,7 +143,7 @@ func stressTestRequest() *networkservice.NetworkServiceRequest {
}
}

func TestTimeoutServer_StressTest_DoubleClose(t *testing.T) {
func TestTimeoutServer_StressTest(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

How long is this test running? Note: we should expect 1s for the unit test.

Copy link
Author

Choose a reason for hiding this comment

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

20ms locally.

Copy link
Author

Choose a reason for hiding this comment

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

build and test (ubuntu-latest)

ok  	github.com/networkservicemesh/sdk/pkg/networkservice/common/serialize	0.896s

build and test (macos-latest)

ok  	github.com/networkservicemesh/sdk/pkg/networkservice/common/serialize	0.760s

build and test (windows-latest) <-- it is actually very slow for all tests

ok  	github.com/networkservicemesh/sdk/pkg/networkservice/common/serialize	1.813s

@Bolodya1997 Bolodya1997 marked this pull request as draft November 27, 2020 09:29
@Bolodya1997 Bolodya1997 marked this pull request as ready for review December 1, 2020 04:46
Copy link
Member

@denis-tingaikin denis-tingaikin left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Vladimir Popov <[email protected]>
Vladimir Popov added 3 commits December 1, 2020 15:21
Signed-off-by: Vladimir Popov <[email protected]>
Signed-off-by: Vladimir Popov <[email protected]>
type contextKeyType string

// IExecutor is a serialize.Executor interface type
type IExecutor interface {
Copy link
Member

@denis-tingaikin denis-tingaikin Dec 1, 2020

Choose a reason for hiding this comment

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

Please lets follow go interface naming convention https://golang.org/doc/effective_go.html#interface-names

Copy link
Author

Choose a reason for hiding this comment

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

Renamed:

IExecutor    ->  Executor
.Executor()  ->  .GetExecutor()

Signed-off-by: Vladimir Popov <[email protected]>
Copy link
Member

@denis-tingaikin denis-tingaikin left a comment

Choose a reason for hiding this comment

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

Merging...

@edwarnicke Let us know if you have something in mind related to these changes.

@denis-tingaikin denis-tingaikin merged commit 98deb86 into networkservicemesh:master Dec 1, 2020
nsmbot pushed a commit to networkservicemesh/sdk-kernel that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
nsmbot pushed a commit to networkservicemesh/cmd-registry-memory that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
nsmbot pushed a commit to networkservicemesh/sdk-vpp that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
nsmbot pushed a commit to networkservicemesh/cmd-registry-proxy-dns that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
nsmbot pushed a commit to networkservicemesh/cmd-nse-icmp-responder that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr-proxy that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
nsmbot pushed a commit to networkservicemesh/sdk-vppagent that referenced this pull request Dec 1, 2020
…k@master networkservicemesh/sdk#583

networkservicemesh/sdk PR link: networkservicemesh/sdk#583

networkservicemesh/sdk commit message:
commit 98deb86e4ee85abd4622882171b79433be93c335
Author: Vladimir Popov <[email protected]>
Date:   Tue Dec 1 18:10:53 2020 +0700

    Serialize chain elements (#583)

    * Add serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework timeout with serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with RequestExecutor, CloseExecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix race condition issue in serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Update github.com/edwarnicke/serialize version

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Fix URL in README

    Signed-off-by: Vladimir Popov <[email protected]>

    * Use atomic.AddUint32() instead of uuid.New().Id()

    Signed-off-by: Vladimir Popov <[email protected]>

    * Add multiexecutor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rework serialize with multi executor

    Signed-off-by: Vladimir Popov <[email protected]>

    * Move multi executor to serialize

    Signed-off-by: Vladimir Popov <[email protected]>

    * Rename `IExecutor` to `Executor`

    Signed-off-by: Vladimir Popov <[email protected]>

Signed-off-by: NSMBot <[email protected]>
illbegood pushed a commit to illbegood/sdk that referenced this pull request Dec 20, 2020
* Add serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rework timeout with serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize with RequestExecutor, CloseExecutor

Signed-off-by: Vladimir Popov <[email protected]>

* Fix race condition issue in serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Update github.com/edwarnicke/serialize version

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Fix URL in README

Signed-off-by: Vladimir Popov <[email protected]>

* Use atomic.AddUint32() instead of uuid.New().Id()

Signed-off-by: Vladimir Popov <[email protected]>

* Add multiexecutor

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize with multi executor

Signed-off-by: Vladimir Popov <[email protected]>

* Move multi executor to serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rename `IExecutor` to `Executor`

Signed-off-by: Vladimir Popov <[email protected]>
Signed-off-by: Sergey Ershov <[email protected]>
illbegood pushed a commit to illbegood/sdk that referenced this pull request Dec 20, 2020
* Add serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rework timeout with serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize with RequestExecutor, CloseExecutor

Signed-off-by: Vladimir Popov <[email protected]>

* Fix race condition issue in serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Update github.com/edwarnicke/serialize version

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Fix URL in README

Signed-off-by: Vladimir Popov <[email protected]>

* Use atomic.AddUint32() instead of uuid.New().Id()

Signed-off-by: Vladimir Popov <[email protected]>

* Add multiexecutor

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize with multi executor

Signed-off-by: Vladimir Popov <[email protected]>

* Move multi executor to serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rename `IExecutor` to `Executor`

Signed-off-by: Vladimir Popov <[email protected]>
Signed-off-by: Sergey Ershov <[email protected]>
illbegood pushed a commit to illbegood/sdk that referenced this pull request Dec 23, 2020
* Add serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rework timeout with serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize with RequestExecutor, CloseExecutor

Signed-off-by: Vladimir Popov <[email protected]>

* Fix race condition issue in serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Update github.com/edwarnicke/serialize version

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Fix URL in README

Signed-off-by: Vladimir Popov <[email protected]>

* Use atomic.AddUint32() instead of uuid.New().Id()

Signed-off-by: Vladimir Popov <[email protected]>

* Add multiexecutor

Signed-off-by: Vladimir Popov <[email protected]>

* Rework serialize with multi executor

Signed-off-by: Vladimir Popov <[email protected]>

* Move multi executor to serialize

Signed-off-by: Vladimir Popov <[email protected]>

* Rename `IExecutor` to `Executor`

Signed-off-by: Vladimir Popov <[email protected]>
Signed-off-by: Sergey Ershov <[email protected]>
@Bolodya1997 Bolodya1997 deleted the serialize branch January 20, 2021 06:32
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.

4 participants