Skip to content

[R4R] #685 expose kafka version#686

Merged
cryptom-dev merged 1 commit intodevelopfrom
kafka_version
Oct 31, 2019
Merged

[R4R] #685 expose kafka version#686
cryptom-dev merged 1 commit intodevelopfrom
kafka_version

Conversation

@cryptom-dev
Copy link
Contributor

@cryptom-dev cryptom-dev commented Oct 31, 2019

Description

expose kafka version

Rationale

@huangsuyu reported a user request this

Example

N/A

Changes

trivial

Preflight checks

  • build passed (make build)
  • tests passed (make test)
  • integration tests passed (make integration_test)
  • manual transaction test passed (cli invoke)

Already reviewed by

...

Related issues

#685

@cryptom-dev
Copy link
Contributor Author

unit test failed:
Test_Expire_3_new
Test_Expire_7_new

image

WARNING: DATA RACE
Read at 0x00c000a66f80 by goroutine 37:
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:563 +0xa8
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Previous write at 0x00c000a66f80 by goroutine 35:
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:563 +0x113
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Goroutine 37 (running) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:562 +0x3192
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199

Goroutine 35 (finished) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:562 +0x3192
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c0001978a0 by goroutine 37:
  runtime.growslice()
      /usr/local/Cellar/go/1.13/libexec/src/runtime/slice.go:76 +0x0
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:563 +0x192
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Previous write at 0x00c0001978a0 by goroutine 35:
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:563 +0xe9
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Goroutine 37 (running) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:562 +0x3192
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199

Goroutine 35 (finished) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_3_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:562 +0x3192
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199
==================
--- FAIL: Test_Expire_3_new (0.11s)
    testing.go:853: race detected during execution of test

WARNING: DATA RACE
Read at 0x00c00000f3a0 by goroutine 83:
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:949 +0xa8
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Previous write at 0x00c00000f3a0 by goroutine 79:
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:949 +0x113
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Goroutine 83 (running) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:948 +0x168a
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199

Goroutine 79 (finished) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:948 +0x168a
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199
==================
==================
WARNING: DATA RACE
Read at 0x00c00107a008 by goroutine 83:
  runtime.growslice()
      /usr/local/Cellar/go/1.13/libexec/src/runtime/slice.go:76 +0x0
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:949 +0x192
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Previous write at 0x00c00107a008 by goroutine 79:
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:949 +0xe9
  github.com/binance-chain/node/plugins/dex/order.(*FeeManager).CalcExpiresFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/fee.go:101 +0x3b7
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocate()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:660 +0x140a
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee.func1()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:769 +0x115

Goroutine 83 (running) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:948 +0x168a
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199

Goroutine 79 (finished) created at:
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).allocateAndCalcFee()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:775 +0x30f
  github.com/binance-chain/node/plugins/dex/order.(*Keeper).ExpireOrders()
      /Users/zhaocong/go/src/github.com/binance-chain/node/plugins/dex/order/keeper.go:895 +0x124
  github.com/binance-chain/node/app/apptest.Test_Expire_7_new()
      /Users/zhaocong/go/src/github.com/binance-chain/node/app/apptest/match_allocation_expire_new_test.go:948 +0x168a
  testing.tRunner()
      /usr/local/Cellar/go/1.13/libexec/src/testing/testing.go:909 +0x199
==================
F22B44CC0D19F52ADD132B7D4B5DD86E62C106D7-0 BTC-000
70DEFE870CA16E264CE3ED3B8494916D6B9CC404-0 ETH-000
--- FAIL: Test_Expire_7_new (0.09s)
    testing.go:853: race detected during execution of test

@EnderCrypto
Copy link
Contributor

Default version should be 2.1.1 instead of 2.1.0?

stopOnKafkaFail = {{ .PublicationConfig.StopOnKafkaFail }}

# kafka broker version, default (and most recommended) is 2.1.0. Minimal supported version could be 0.8.2 (not well tested)
kafkaVersion = "{{ .PublicationConfig.KafkaVersion }}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Description how this is used: please modify the default value into the version of Kafka you are using.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Description how this is used: please modify the default value into the version of Kafka you are using.

I think this is intuitive, in config template, we should show users valid values... i.e. for

# Whether we want publish block
publishBlock = {{ .PublicationConfig.PublishBlock }}	publishBlock = {{ .PublicationConfig.PublishBlock }}

we don't say: "please modify the value into true if you want use publish block information."

Copy link
Contributor

Choose a reason for hiding this comment

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

remove the quotation mark

Copy link
Contributor

@unclezoro unclezoro Oct 31, 2019

Choose a reason for hiding this comment

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

Description how this is used: please modify the default value into the version of Kafka you are using.

I think this is intuitive, in config template, we should show users valid values... i.e. for

# Whether we want publish block
publishBlock = {{ .PublicationConfig.PublishBlock }}	publishBlock = {{ .PublicationConfig.PublishBlock }}

we don't say: "please modify the value into true if you want use publish block information."

This config is quite different from publishBlock, since it it up to user to decide to choose use publishBlock or not, but we are highly recommend user to modify kafkaVersion if he use Kafka and just leave it as default, what is the meaning of this config? It will just show a wrong version. Better highlight this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This config is quite different from publishBlock, since it it up to user to decide to choose use publishBlock or not, but we are highly recommend user to modify kafkaVersion if he use Kafka and just leave it as default, what is the meaning of this config? It will just show a wrong version. Better highlight this.

Although I didn't agree, I will add this line as its no harm.
If publishBlock is a bad example. Configs like OrderUpdatesKafka and OrderUpdatesTopic are all configs have default value which 99% didn't match user's configuration. (I presume no one deployed kafka at localhost of their node, and auto.create.topic options is default to false on broker side). We don't say please modify the default value into the ip:port of Kafka you are using. and please modify the default value into the topic of your Kafka admin gave you.. User touch this publication section because they want to customize default configurations.

}

func (publisher *KafkaMarketDataPublisher) newProducers() (config *sarama.Config, err error) {
version, err := sarama.ParseKafkaVersion(Cfg.KafkaVersion)
Copy link
Contributor

@unclezoro unclezoro Oct 31, 2019

Choose a reason for hiding this comment

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

won't you check the support range? The is the only motivation that user modify app.toml

Copy link
Contributor

Choose a reason for hiding this comment

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

the version should be within the sarama.SupportedVersions

Copy link
Contributor

Choose a reason for hiding this comment

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

also, do we use any features that some old versions do not support even if they are in the sarama.SupportedVersions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also, do we use any features that some old versions do not support even if they are in the sarama.SupportedVersions

no, we use basic publication functionalities. Message format are not compatible between versions, but if publisher/broker/consumer are same version, there should be no issue

Copy link
Contributor Author

@cryptom-dev cryptom-dev Oct 31, 2019

Choose a reason for hiding this comment

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

won't you check the support range? The is the only motivation that user modify app.toml

I added an error if user specified an invalid version:
panic: kafka version in app.toml is not supported. Please choose a version within: [0.8.2.0 0.8.2.1 0.8.2.2 0.9.0.0 0.9.0.1 0.10.0.0 0.10.0.1 0.10.1.0 0.10.1.1 0.10.2.0 0.10.2.1 0.11.0.0 0.11.0.1 0.11.0.2 1.0.0 1.1.0 1.1.1 2.0.0 2.0.1 2.1.0]

@cryptom-dev
Copy link
Contributor Author

Default version should be 2.1.1 instead of 2.1.0?

sarama didn't officially support 2.1.1, if we set default version to 2.1.1, we cannot uni test it.

	SupportedVersions = []KafkaVersion{
		V0_8_2_0,
		V0_8_2_1,
		V0_8_2_2,
		V0_9_0_0,
		V0_9_0_1,
		V0_10_0_0,
		V0_10_0_1,
		V0_10_1_0,
		V0_10_1_1,
		V0_10_2_0,
		V0_10_2_1,
		V0_11_0_0,
		V0_11_0_1,
		V0_11_0_2,
		V1_0_0_0,
		V1_1_0_0,
		V1_1_1_0,
		V2_0_0_0,
		V2_0_1_0,
		V2_1_0_0,
	}

@cryptom-dev cryptom-dev merged commit 48f6be4 into develop Oct 31, 2019
@unclezoro unclezoro deleted the kafka_version branch May 10, 2022 06:14
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.

5 participants