CECTC / dbpack

A db proxy for distributed transaction, read write splitting and sharding! Support any language! It can be deployed as a sidecar in a pod.
https://cectc.github.io/dbpack-doc/#/en-us/
Apache License 2.0
356 stars 46 forks source link

fix: finished distributed pk feature #276

Closed hzliangbin closed 2 years ago

hzliangbin commented 2 years ago

ref: https://github.com/cectc/dbpack/issues/42

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fix #42

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

docker-compose run it on sharding mode, execute go test test/shd/shardng_test.go

there is a test case to verify insert without PK, and it is set to use "snowflake" uuid generator by default

Ⅴ. Special notes for reviews

1000 or much more IDs to a INT64 channel, dbpack just take it from channel. It's more simple but also did a good job.

hzliangbin commented 2 years ago

@bohehe @zackzhangkai @wybrobin @zhu733756 PTAL

dk-lockdown commented 2 years ago

pls run make fmt to format the code

codecov-commenter commented 2 years ago

Codecov Report

Merging #276 (eb81364) into dev (1c353ea) will increase coverage by 0.04%. The diff coverage is 15.00%.

:exclamation: Current head eb81364 differs from pull request most recent head 5c0e422. Consider uploading reports for the commit 5c0e422 to get more accurate results

@@            Coverage Diff             @@
##              dev     #276      +/-   ##
==========================================
+ Coverage   42.53%   42.57%   +0.04%     
==========================================
  Files          90       90              
  Lines       10349    10350       +1     
==========================================
+ Hits         4402     4407       +5     
+ Misses       5472     5466       -6     
- Partials      475      477       +2     
Impacted Files Coverage Δ
pkg/cond/algo_number_mod.go 19.53% <0.00%> (-0.47%) :arrow_down:
pkg/cond/algo_number_range.go 44.24% <0.00%> (-0.82%) :arrow_down:
pkg/cond/sharding_algorithm.go 0.00% <0.00%> (ø)
pkg/misc/uuid/segment.go 0.00% <0.00%> (ø)
pkg/misc/uuid/snowflake.go 0.00% <0.00%> (ø)
pkg/executor/sharding.go 36.68% <42.85%> (-0.48%) :arrow_down:
pkg/optimize/optimize_insert.go 64.00% <50.00%> (-0.79%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more