From 58ecb0ddc35d8368dad1f8ac06ff3adaf01f4bbd Mon Sep 17 00:00:00 2001 From: Shanicky Chen Date: Tue, 19 Sep 2023 18:05:01 +0800 Subject: [PATCH] Add new packages, dependencies to Cargo.lock, and modify Cargo.toml. Code changes: import `EtcdElectionClient`, update import path, define `ElectionHandle` as tuple. Added new code block for #[cfg(not(madsim))] and #[cfg(test)] module. --- Cargo.lock | 605 +++++++++++++---- src/meta/Cargo.toml | 1 + src/meta/src/error.rs | 13 +- .../{election_client.rs => election/etcd.rs} | 23 +- src/meta/src/rpc/election/mod.rs | 38 ++ src/meta/src/rpc/election/sql.rs | 625 ++++++++++++++++++ src/meta/src/rpc/mod.rs | 5 +- src/meta/src/rpc/server.rs | 3 +- src/workspace-hack/Cargo.toml | 70 +- 9 files changed, 1228 insertions(+), 155 deletions(-) rename src/meta/src/rpc/{election_client.rs => election/etcd.rs} (96%) create mode 100644 src/meta/src/rpc/election/mod.rs create mode 100644 src/meta/src/rpc/election/sql.rs diff --git a/Cargo.lock b/Cargo.lock index 12f7be03b7d2c..467daacddb150 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,9 +114,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" +checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46" [[package]] name = "anstyle-parse" @@ -220,7 +220,7 @@ dependencies = [ "proc-macro2", "quote", "serde_json", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -317,7 +317,7 @@ dependencies = [ "arrow-cast", "arrow-ipc", "arrow-schema", - "base64 0.21.3", + "base64 0.21.4", "bytes", "futures", "paste", @@ -419,7 +419,7 @@ version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8257238e2a3629ee5618502a75d1b91f8017c24638c75349fc8d2d80cf1f7c4c" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "futures", "http", @@ -433,7 +433,7 @@ dependencies = [ "ring", "rustls-native-certs", "rustls-pemfile", - "rustls-webpki 0.101.4", + "rustls-webpki 0.101.5", "serde", "serde_json", "serde_nanos", @@ -455,7 +455,7 @@ checksum = "5fd55a5ba1179988837d24ab4c7cc8ed6efdeff578ede0416b4225a5fca35bd0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -477,7 +477,7 @@ checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -494,7 +494,16 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", +] + +[[package]] +name = "atoi" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f28d99ec8bfea296261ca1af174f24225171fea9664ba9003cbebee704810528" +dependencies = [ + "num-traits", ] [[package]] @@ -512,7 +521,7 @@ dependencies = [ "derive_utils", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -1042,9 +1051,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.3" +version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" +checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" [[package]] name = "base64-simd" @@ -1062,7 +1071,7 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c5b0a88aa36e9f095ee2e2b13fb8c5e4313e022783aedacc123328c0084916d" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", ] [[package]] @@ -1132,11 +1141,11 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.59.2" +version = "0.68.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" +checksum = "726e4313eb6ec35d2730258ad4e15b547ee75d6afaa1361a922e78e59b7d8078" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "cexpr", "clang-sys", "lazy_static", @@ -1147,6 +1156,7 @@ dependencies = [ "regex", "rustc-hash", "shlex", + "syn 2.0.37", ] [[package]] @@ -1175,6 +1185,9 @@ name = "bitflags" version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +dependencies = [ + "serde", +] [[package]] name = "bitmaps" @@ -1290,9 +1303,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" +checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" [[package]] name = "bytecheck" @@ -1459,7 +1472,7 @@ checksum = "bc7cb2538d4ecc42b6c3b57a83094d8c69894e74468d18cd045a09fdea807358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -1541,9 +1554,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.4.3" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84ed82781cea27b43c9b106a979fe450a13a31aab0500595fb3fc06616de08e6" +checksum = "b1d7b8d5ec32af0fadc644bf1fd509a688c2103b185644bb1e29d164e0703136" dependencies = [ "clap_builder", "clap_derive", @@ -1551,9 +1564,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.2" +version = "4.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" +checksum = "5179bb514e4d7c2051749d8fcefa2ed6d06a9f4e6d69faf3805f5d80b8cf8d56" dependencies = [ "anstream", "anstyle", @@ -1570,7 +1583,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -1858,7 +1871,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2051,7 +2064,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" dependencies = [ "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2078,7 +2091,7 @@ checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2105,7 +2118,7 @@ dependencies = [ "proc-macro2", "quote", "scratch", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2122,7 +2135,7 @@ checksum = "2fa16a70dd58129e4dfffdff535fb1bce66673f7bbeec4a5a1765a504e1ccd84" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2194,7 +2207,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2227,7 +2240,7 @@ checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ "darling_core 0.20.3", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2338,7 +2351,7 @@ checksum = "9abcad25e9720609ccb3dcdb795d845e37d8ce34183330a9f48b03a1a71c8e21" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2392,6 +2405,12 @@ dependencies = [ "const-random", ] +[[package]] +name = "dotenvy" +version = "0.15.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b" + [[package]] name = "downcast" version = "0.11.0" @@ -2432,9 +2451,9 @@ dependencies = [ [[package]] name = "dyn-clone" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbfc4744c1b8f2a09adc0e55242f60b1af195d88596bd8700be74418c056c555" +checksum = "23d2f3407d9a573d666de4b5bdf10569d73ca9478087346697dcbae6244bfbcd" [[package]] name = "easy-ext" @@ -2480,6 +2499,9 @@ name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +dependencies = [ + "serde", +] [[package]] name = "encode_unicode" @@ -2505,7 +2527,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2525,7 +2547,7 @@ checksum = "eecf8589574ce9b895052fa12d69af7a233f99e6107f5cb8dd1044f2a17bfdcb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2538,7 +2560,7 @@ dependencies = [ "num-traits", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2605,6 +2627,17 @@ dependencies = [ "tower-service", ] +[[package]] +name = "etcetera" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943" +dependencies = [ + "cfg-if", + "home", + "windows-sys 0.48.0", +] + [[package]] name = "ethnum" version = "1.4.0" @@ -2722,9 +2755,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" [[package]] name = "flagset" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cda653ca797810c02f7ca4b804b40b8b95ae046eb989d356bce17919a8c25499" +checksum = "d52a7e408202050813e6f1d9addadcaafef3dca7530c7ddfb005d4081cce6779" [[package]] name = "flatbuffers" @@ -2765,6 +2798,18 @@ dependencies = [ "num-traits", ] +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project", + "spin 0.9.8", +] + [[package]] name = "fnv" version = "1.0.7" @@ -2891,7 +2936,7 @@ dependencies = [ "regex", "regex-automata 0.3.8", "regex-syntax 0.7.5", - "syn 2.0.33", + "syn 2.0.37", "tokio", "tracing", "tracing-core", @@ -2928,7 +2973,7 @@ checksum = "b0fa992f1656e1707946bbba340ad244f0814009ef8c0118eb7b658395f19a2e" dependencies = [ "frunk_proc_macro_helpers", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2940,7 +2985,7 @@ dependencies = [ "frunk_core", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -2952,7 +2997,7 @@ dependencies = [ "frunk_core", "frunk_proc_macro_helpers", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -3056,6 +3101,17 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-intrusive" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d930c203dd0b6ff06e0201a4a2fe9149b43c684fd4420555b26d21b1a02956f" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot 0.12.1", +] + [[package]] name = "futures-io" version = "0.3.28" @@ -3070,7 +3126,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -3172,7 +3228,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "931bedb2264cb00f914b0a6a5c304e34865c34306632d3932e0951a073e4a67d" dependencies = [ "async-trait", - "base64 0.21.3", + "base64 0.21.4", "google-cloud-metadata", "google-cloud-token", "home", @@ -3344,6 +3400,15 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashlink" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8094feaf31ff591f651a2664fb9cfd92bba7a60ce3197265e9482ebe753c8f7" +dependencies = [ + "hashbrown 0.14.0", +] + [[package]] name = "hdrhistogram" version = "7.5.2" @@ -3372,6 +3437,9 @@ name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" +dependencies = [ + "unicode-segmentation", +] [[package]] name = "hermit-abi" @@ -3385,6 +3453,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hkdf" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791a029f6b9fc27657f6f188ec6e5e43f6911f6f878e0dc5501396e09809d437" +dependencies = [ + "hmac", +] + [[package]] name = "hmac" version = "0.12.1" @@ -3668,9 +3745,9 @@ dependencies = [ [[package]] name = "inferno" -version = "0.11.16" +version = "0.11.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73c0fefcb6d409a6587c07515951495d482006f89a21daa0f2f783aa4fd5e027" +checksum = "c50453ec3a6555fad17b1cd1a80d16af5bc7cb35094f64e429fd46549018c6a3" dependencies = [ "ahash 0.8.3", "indexmap 2.0.0", @@ -3739,7 +3816,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.11", + "rustix 0.38.13", "windows-sys 0.48.0", ] @@ -3846,7 +3923,7 @@ version = "8.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6971da4d9c3aa03c3d8f3ff0f4155b534aad021292003895a469716b2a230378" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "pem 1.1.1", "ring", "serde", @@ -3993,6 +4070,17 @@ version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7012b1bbb0719e1097c47611d3898568c546d597c2e74d66f6087edd5233ff4" +[[package]] +name = "libsqlite3-sys" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afc22eff61b133b115c6e8c74e818c628d6d5e7a502afea6f64dee076dd94326" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + [[package]] name = "libtest-mimic" version = "0.6.1" @@ -4039,9 +4127,9 @@ checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" [[package]] name = "linux-raw-sys" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" +checksum = "1a9bad9f94746442c783ca431b22403b519cd7fbeed0533fdd6328b2f2212128" [[package]] name = "local_stats_alloc" @@ -4486,7 +4574,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", "termcolor", "thiserror", ] @@ -4515,7 +4603,7 @@ dependencies = [ "priority-queue", "serde", "serde_json", - "socket2 0.5.3", + "socket2 0.5.4", "thiserror", "tokio", "tokio-native-tls", @@ -4530,7 +4618,7 @@ version = "0.30.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57349d5a326b437989b6ee4dc8f2f34b0cc131202748414712a8e7d98952fc8c" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bigdecimal", "bindgen", "bitflags 2.4.0", @@ -4903,7 +4991,7 @@ dependencies = [ "async-compat", "async-trait", "backon", - "base64 0.21.3", + "base64 0.21.4", "bytes", "chrono", "flagset", @@ -4976,7 +5064,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -4987,9 +5075,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "111.25.3+1.1.1t" +version = "111.28.0+1.1.1w" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "924757a6a226bf60da5f7dd0311a34d2b52283dd82ddeb103208ddc66362f80c" +checksum = "3ce95ee1f6f999dfb95b8afd43ebe442758ea2104d1ccb99a94c30db22ae701f" dependencies = [ "cc", ] @@ -5223,7 +5311,7 @@ dependencies = [ "arrow-ipc", "arrow-schema", "arrow-select", - "base64 0.21.3", + "base64 0.21.4", "brotli", "bytes", "chrono", @@ -5265,7 +5353,7 @@ dependencies = [ "regex", "regex-syntax 0.7.5", "structmeta", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -5307,7 +5395,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1030c719b0ec2a2d25a5df729d6cff1acf3cc230bf766f4f97833591f7577b90" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "serde", ] @@ -5344,7 +5432,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b13fe415cdf3c8e44518e18a7c95a13431d9bdf6d15367d82b23c377fdd441a" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "serde", ] @@ -5400,7 +5488,7 @@ dependencies = [ "risingwave_sqlparser", "thiserror", "tokio-openssl", - "tokio-postgres", + "tokio-postgres 0.7.8", "tracing", "workspace-hack", ] @@ -5461,7 +5549,7 @@ checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -5545,16 +5633,16 @@ checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b" [[package]] name = "postgres" -version = "0.19.5" +version = "0.19.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bed5017bc2ff49649c0075d0d7a9d676933c1292480c1d137776fb205b5cd18" +checksum = "7915b33ed60abc46040cbcaa25ffa1c7ec240668e0477c4f3070786f5916d451" dependencies = [ "bytes", "fallible-iterator", "futures-util", "log", "tokio", - "tokio-postgres", + "tokio-postgres 0.7.10", ] [[package]] @@ -5566,7 +5654,7 @@ dependencies = [ "heck 0.4.1", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -5575,7 +5663,7 @@ version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49b6c5ef183cd3ab4ba005f1ca64c21e8bd97ce4699cfea9e8d9a2c4958ca520" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "byteorder", "bytes", "fallible-iterator", @@ -5876,7 +5964,7 @@ version = "0.1.0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", "workspace-hack", ] @@ -6236,7 +6324,7 @@ checksum = "3228e570df74d69d3d3236a71371f1edd748a3e4eb728ea1f29d403bc10fc727" dependencies = [ "anyhow", "async-trait", - "base64 0.21.3", + "base64 0.21.4", "chrono", "form_urlencoded", "hex", @@ -6265,7 +6353,7 @@ version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "bytes", "encoding_rs", "futures-core", @@ -6762,7 +6850,7 @@ dependencies = [ "aws-sdk-s3", "aws-smithy-http", "aws-types", - "base64 0.21.3", + "base64 0.21.4", "bincode 1.3.3", "byteorder", "bytes", @@ -6870,7 +6958,7 @@ dependencies = [ "madsim-tokio", "pg_interval", "rust_decimal", - "tokio-postgres", + "tokio-postgres 0.7.8", "tracing", "tracing-subscriber", ] @@ -6931,7 +7019,7 @@ dependencies = [ "itertools 0.11.0", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -7155,6 +7243,7 @@ dependencies = [ "scopeguard", "serde", "serde_json", + "sqlx", "static_assertions", "sync-point", "tempfile", @@ -7346,7 +7435,7 @@ dependencies = [ "sqllogictest", "tempfile", "tikv-jemallocator", - "tokio-postgres", + "tokio-postgres 0.7.8", "tracing", "tracing-subscriber", ] @@ -7421,7 +7510,7 @@ dependencies = [ "risingwave_pb", "risingwave_sqlparser", "similar", - "tokio-postgres", + "tokio-postgres 0.7.8", "tracing", "tracing-subscriber", "workspace-hack", @@ -7440,7 +7529,7 @@ dependencies = [ "risingwave_rt", "serde", "serde_with 3.3.0", - "tokio-postgres", + "tokio-postgres 0.7.8", "tokio-stream", "toml 0.7.8", "tracing", @@ -7735,14 +7824,14 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.11" +version = "0.38.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" +checksum = "d7db8590df6dfcd144d22afd1b83b36c21a18d7cbc1dc4bb5295a8712e9eb662" dependencies = [ "bitflags 2.4.0", "errno", "libc", - "linux-raw-sys 0.4.5", + "linux-raw-sys 0.4.7", "windows-sys 0.48.0", ] @@ -7766,7 +7855,7 @@ checksum = "cd8d6c9f025a446bc4d18ad9632e69aec8f287aa84499ee335599fabd20c3fd8" dependencies = [ "log", "ring", - "rustls-webpki 0.101.4", + "rustls-webpki 0.101.5", "sct", ] @@ -7788,14 +7877,14 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3987094b1d07b653b7dfdc3f70ce9a1da9c51ac18c1b06b662e4f9a0e9f4b2" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", ] [[package]] name = "rustls-webpki" -version = "0.100.2" +version = "0.100.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e98ff011474fa39949b7e5c0428f9b4937eda7da7848bbb947786b7be0b27dab" +checksum = "5f6a5fc258f1c1276dfe3016516945546e2d5383911efc0fc4f1cdc5df3a4ae3" dependencies = [ "ring", "untrusted", @@ -7803,9 +7892,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.4" +version = "0.101.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d93931baf2d282fff8d3a532bbfd7653f734643161b87e3e01e59a04439bf0d" +checksum = "45a27e3b59326c16e23d30aeb7a36a24cc0d29e71d68ff611cdfb4a01d013bed" dependencies = [ "ring", "untrusted", @@ -8010,7 +8099,7 @@ checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8071,7 +8160,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8127,7 +8216,7 @@ version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ca3b16a3d82c4088f343b7480a93550b3eabe1a358569c2dfe38bbcead07237" dependencies = [ - "base64 0.21.3", + "base64 0.21.4", "chrono", "hex", "indexmap 1.9.3", @@ -8159,7 +8248,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8171,7 +8260,7 @@ dependencies = [ "darling 0.20.3", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8209,7 +8298,7 @@ checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8325,10 +8414,11 @@ dependencies = [ [[package]] name = "simd-json" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de7f1293f0e4e11d52e588766fe9de8caa2857ff63809d40de83245452ca7c5c" +checksum = "80ea1dfc2c400965867fc4ddd6f502572be2de2074b39f90984ed15fbdbdd8eb" dependencies = [ + "getrandom", "halfbrown", "lexical-core", "serde", @@ -8449,9 +8539,9 @@ dependencies = [ [[package]] name = "socket2" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877" +checksum = "4031e820eb552adee9295814c0ced9e5cf38ddf1e8b7d566d6de8e2538ea989e" dependencies = [ "libc", "windows-sys 0.48.0", @@ -8492,6 +8582,17 @@ dependencies = [ "der", ] +[[package]] +name = "sqlformat" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b7b278788e7be4d0d29c0f39497a0eef3fba6bbc8e70d8bf7fde46edeaa9e85" +dependencies = [ + "itertools 0.11.0", + "nom", + "unicode_categories", +] + [[package]] name = "sqllogictest" version = "0.15.3" @@ -8515,6 +8616,205 @@ dependencies = [ "tracing", ] +[[package]] +name = "sqlx" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e58421b6bc416714d5115a2ca953718f6c621a51b68e4f4922aea5a4391a721" +dependencies = [ + "sqlx-core", + "sqlx-macros", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", +] + +[[package]] +name = "sqlx-core" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd4cef4251aabbae751a3710927945901ee1d97ee96d757f6880ebb9a79bfd53" +dependencies = [ + "ahash 0.8.3", + "atoi", + "byteorder", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener", + "futures-channel", + "futures-core", + "futures-intrusive", + "futures-io", + "futures-util", + "hashlink", + "hex", + "indexmap 2.0.0", + "log", + "memchr", + "once_cell", + "paste", + "percent-encoding", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "thiserror", + "tokio", + "tokio-stream", + "tracing", + "url", +] + +[[package]] +name = "sqlx-macros" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "208e3165167afd7f3881b16c1ef3f2af69fa75980897aac8874a0696516d12c2" +dependencies = [ + "proc-macro2", + "quote", + "sqlx-core", + "sqlx-macros-core", + "syn 1.0.109", +] + +[[package]] +name = "sqlx-macros-core" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a4a8336d278c62231d87f24e8a7a74898156e34c1c18942857be2acb29c7dfc" +dependencies = [ + "dotenvy", + "either", + "heck 0.4.1", + "hex", + "once_cell", + "proc-macro2", + "quote", + "serde", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", + "syn 1.0.109", + "tempfile", + "tokio", + "url", +] + +[[package]] +name = "sqlx-mysql" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ca69bf415b93b60b80dc8fda3cb4ef52b2336614d8da2de5456cc942a110482" +dependencies = [ + "atoi", + "base64 0.21.4", + "bitflags 2.4.0", + "byteorder", + "bytes", + "chrono", + "crc", + "digest", + "dotenvy", + "either", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "generic-array", + "hex", + "hkdf", + "hmac", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "percent-encoding", + "rand", + "rsa", + "serde", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-postgres" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0db2df1b8731c3651e204629dd55e52adbae0462fa1bdcbed56a2302c18181e" +dependencies = [ + "atoi", + "base64 0.21.4", + "bitflags 2.4.0", + "byteorder", + "chrono", + "crc", + "dotenvy", + "etcetera", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "hex", + "hkdf", + "hmac", + "home", + "itoa", + "log", + "md-5", + "memchr", + "once_cell", + "rand", + "serde", + "serde_json", + "sha1", + "sha2", + "smallvec", + "sqlx-core", + "stringprep", + "thiserror", + "tracing", + "whoami", +] + +[[package]] +name = "sqlx-sqlite" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4c21bf34c7cae5b283efb3ac1bcc7670df7561124dc2f8bdc0b59be40f79a2" +dependencies = [ + "atoi", + "chrono", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "libsqlite3-sys", + "log", + "percent-encoding", + "serde", + "sqlx-core", + "tracing", + "url", +] + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -8559,7 +8859,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8570,7 +8870,7 @@ checksum = "a60bcaff7397072dca0017d1db428e30d5002e00b6847703e2e42005c95fbe00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8611,7 +8911,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8666,9 +8966,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.33" +version = "2.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9caece70c63bfba29ec2fed841a09851b14a235c60010fa4de58089b6c025668" +checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" dependencies = [ "proc-macro2", "quote", @@ -8734,15 +9034,15 @@ dependencies = [ "cfg-if", "fastrand 2.0.0", "redox_syscall 0.3.5", - "rustix 0.38.11", + "rustix 0.38.13", "windows-sys 0.48.0", ] [[package]] name = "termcolor" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" +checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64" dependencies = [ "winapi-util", ] @@ -8770,7 +9070,7 @@ checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -8920,7 +9220,7 @@ dependencies = [ "parking_lot 0.12.1", "pin-project-lite", "signal-hook-registry", - "socket2 0.5.3", + "socket2 0.5.4", "tokio-macros", "tracing", "windows-sys 0.48.0", @@ -8944,7 +9244,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -9000,8 +9300,34 @@ dependencies = [ "pin-project-lite", "postgres-protocol", "postgres-types", - "socket2 0.5.3", + "socket2 0.5.4", + "tokio-util", +] + +[[package]] +name = "tokio-postgres" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d340244b32d920260ae7448cb72b6e238bddc3d4f7603394e7dd46ed8e48f5b8" +dependencies = [ + "async-trait", + "byteorder", + "bytes", + "fallible-iterator", + "futures-channel", + "futures-util", + "log", + "parking_lot 0.12.1", + "percent-encoding", + "phf", + "pin-project-lite", + "postgres-protocol", + "postgres-types", + "rand", + "socket2 0.5.4", + "tokio", "tokio-util", + "whoami", ] [[package]] @@ -9111,7 +9437,7 @@ dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.3", + "base64 0.21.4", "bytes", "flate2", "futures-core", @@ -9226,7 +9552,7 @@ checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] @@ -9376,9 +9702,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.16.0" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "uncased" @@ -9406,9 +9732,9 @@ checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-normalization" @@ -9431,6 +9757,12 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + [[package]] name = "unsafe-libyaml" version = "0.2.9" @@ -9586,7 +9918,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", "wasm-bindgen-shared", ] @@ -9620,7 +9952,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -9670,7 +10002,7 @@ version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b03058f88386e5ff5310d9111d53f48b17d732b401aeb83a8d5190f2ac459338" dependencies = [ - "rustls-webpki 0.100.2", + "rustls-webpki 0.100.3", ] [[package]] @@ -9688,7 +10020,17 @@ dependencies = [ "either", "home", "once_cell", - "rustix 0.38.11", + "rustix 0.38.13", +] + +[[package]] +name = "whoami" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22fc3756b8a9133049b26c7f61ab35416c130e8c09b660f5b3958b446f52cc50" +dependencies = [ + "wasm-bindgen", + "web-sys", ] [[package]] @@ -9898,14 +10240,16 @@ name = "workspace-hack" version = "1.3.0-alpha" dependencies = [ "ahash 0.8.3", + "allocator-api2", "anyhow", "auto_enums", "aws-credential-types", "aws-sdk-s3", "aws-smithy-client", - "base64 0.21.3", + "base64 0.21.4", "bit-vec", "bitflags 2.4.0", + "byteorder", "bytes", "cc", "chrono", @@ -9913,8 +10257,10 @@ dependencies = [ "clap_builder", "combine", "crossbeam-epoch", + "crossbeam-queue", "crossbeam-utils", "deranged", + "digest", "either", "fail", "fixedbitset", @@ -9929,10 +10275,12 @@ dependencies = [ "futures-util", "hashbrown 0.12.3", "hashbrown 0.14.0", + "heck 0.4.1", "hyper", "indexmap 1.9.3", "itertools 0.10.5", "jni", + "lazy_static", "lexical-core", "lexical-parse-float", "lexical-parse-integer", @@ -9944,11 +10292,13 @@ dependencies = [ "log", "madsim-rdkafka", "madsim-tokio", + "md-5", "mio", "multimap", "nom", "num-bigint", "num-integer", + "num-iter", "num-traits", "opentelemetry_api", "opentelemetry_sdk", @@ -9974,15 +10324,23 @@ dependencies = [ "serde", "serde_json", "serde_with 3.3.0", + "sha1", + "sha2", + "signature", "smallvec", + "socket2 0.5.4", + "sqlx-core", + "sqlx-mysql", + "sqlx-postgres", + "sqlx-sqlite", "subtle", "syn 1.0.109", - "syn 2.0.33", + "syn 2.0.37", "time", "time-macros", "tinyvec", "tokio", - "tokio-postgres", + "tokio-postgres 0.7.8", "tokio-stream", "tokio-util", "toml_datetime", @@ -9996,6 +10354,7 @@ dependencies = [ "unicode-normalization", "url", "uuid", + "whoami", ] [[package]] @@ -10071,7 +10430,7 @@ checksum = "56097d5b91d711293a42be9289403896b68654625021732067eac7a4ca388a1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.33", + "syn 2.0.37", ] [[package]] diff --git a/src/meta/Cargo.toml b/src/meta/Cargo.toml index cd81265e5f733..329fb4fdc1fda 100644 --- a/src/meta/Cargo.toml +++ b/src/meta/Cargo.toml @@ -57,6 +57,7 @@ risingwave_sqlparser = { workspace = true } scopeguard = "1.2.0" serde = { version = "1", features = ["derive"] } serde_json = "1" +sqlx = { version = "0.7", features = ["runtime-tokio", "postgres", "mysql", "sqlite", "chrono"] } sync-point = { path = "../utils/sync-point" } thiserror = "1" tokio = { version = "0.2", package = "madsim-tokio", features = [ diff --git a/src/meta/src/error.rs b/src/meta/src/error.rs index b6c86b3f1eec0..b056fea0e35e7 100644 --- a/src/meta/src/error.rs +++ b/src/meta/src/error.rs @@ -20,6 +20,7 @@ use risingwave_common::error::BoxedError; use risingwave_connector::sink::SinkError; use risingwave_pb::PbFieldNotFound; use risingwave_rpc_client::error::RpcError; +use sqlx::Error; use crate::hummock::error::Error as HummockError; use crate::manager::WorkerId; @@ -62,7 +63,7 @@ enum MetaErrorInner { Unavailable(String), #[error("Election failed: {0}")] - Election(etcd_client::Error), + Election(String), #[error("Cancelled: {0}")] Cancelled(String), @@ -73,7 +74,7 @@ enum MetaErrorInner { #[error("Sink error: {0}")] Sink(SinkError), - #[error("AWS SDK error: {}", DisplayErrorContext(&**.0))] + #[error("AWS SDK error: {}", DisplayErrorContext(& * *.0))] Aws(BoxedError), #[error(transparent)] @@ -165,7 +166,13 @@ impl From for MetaError { impl From for MetaError { fn from(e: etcd_client::Error) -> Self { - MetaErrorInner::Election(e).into() + MetaErrorInner::Election(e.to_string()).into() + } +} + +impl From for MetaError { + fn from(value: Error) -> Self { + MetaErrorInner::Election(value.to_string()).into() } } diff --git a/src/meta/src/rpc/election_client.rs b/src/meta/src/rpc/election/etcd.rs similarity index 96% rename from src/meta/src/rpc/election_client.rs rename to src/meta/src/rpc/election/etcd.rs index fdc9f9b3bc2dd..f30d8253cb95d 100644 --- a/src/meta/src/rpc/election_client.rs +++ b/src/meta/src/rpc/election/etcd.rs @@ -18,33 +18,15 @@ use std::time::Duration; use etcd_client::{ConnectOptions, Error, GetOptions, LeaderKey, ResignOptions}; use risingwave_common::bail; -use serde::Serialize; use tokio::sync::watch::Receiver; use tokio::sync::{oneshot, watch}; use tokio::time; use tokio_stream::StreamExt; +use crate::rpc::election::{ElectionClient, ElectionMember, META_ELECTION_KEY}; use crate::storage::WrappedEtcdClient; use crate::MetaResult; -const META_ELECTION_KEY: &str = "__meta_election_"; - -#[derive(Debug, Serialize)] -pub struct ElectionMember { - pub id: String, - pub is_leader: bool, -} - -#[async_trait::async_trait] -pub trait ElectionClient: Send + Sync + 'static { - fn id(&self) -> MetaResult; - async fn run_once(&self, ttl: i64, stop: Receiver<()>) -> MetaResult<()>; - fn subscribe(&self) -> Receiver; - async fn leader(&self) -> MetaResult>; - async fn get_members(&self) -> MetaResult>; - async fn is_leader(&self) -> bool; -} - pub struct EtcdElectionClient { id: String, is_leader_sender: watch::Sender, @@ -367,7 +349,8 @@ mod tests { use tokio::sync::watch::Sender; use tokio::time; - use crate::rpc::election_client::{ElectionClient, EtcdElectionClient, META_ELECTION_KEY}; + use crate::rpc::election::etcd::EtcdElectionClient; + use crate::rpc::election::{ElectionClient, META_ELECTION_KEY}; type ElectionHandle = (Sender<()>, Arc); diff --git a/src/meta/src/rpc/election/mod.rs b/src/meta/src/rpc/election/mod.rs new file mode 100644 index 0000000000000..9835c554b3fd3 --- /dev/null +++ b/src/meta/src/rpc/election/mod.rs @@ -0,0 +1,38 @@ +// Copyright 2023 RisingWave Labs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +pub mod etcd; +pub mod sql; + +use serde::Serialize; +use tokio::sync::watch::Receiver; + +use crate::MetaResult; + +const META_ELECTION_KEY: &str = "__meta_election_"; + +#[derive(Debug, Serialize)] +pub struct ElectionMember { + pub id: String, + pub is_leader: bool, +} + +#[async_trait::async_trait] +pub trait ElectionClient: Send + Sync + 'static { + fn id(&self) -> MetaResult; + async fn run_once(&self, ttl: i64, stop: Receiver<()>) -> MetaResult<()>; + fn subscribe(&self) -> Receiver; + async fn leader(&self) -> MetaResult>; + async fn get_members(&self) -> MetaResult>; + async fn is_leader(&self) -> bool; +} diff --git a/src/meta/src/rpc/election/sql.rs b/src/meta/src/rpc/election/sql.rs new file mode 100644 index 0000000000000..b6bd02b179c26 --- /dev/null +++ b/src/meta/src/rpc/election/sql.rs @@ -0,0 +1,625 @@ +// Copyright 2023 RisingWave Labs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use std::sync::Arc; +use std::time::Duration; + +use sqlx::{MySql, MySqlPool, PgPool, Postgres, Sqlite, SqlitePool}; +use tokio::sync::watch; +use tokio::sync::watch::Receiver; +use tokio::time; + +use crate::rpc::election::META_ELECTION_KEY; +use crate::{ElectionClient, ElectionMember, MetaResult}; + +pub struct SqlBackendElectionClient { + id: String, + driver: Arc, + is_leader_sender: watch::Sender, +} + +#[derive(sqlx::FromRow, Debug)] +pub(crate) struct ElectionRow { + service: String, + id: String, +} + +#[async_trait::async_trait] +pub(crate) trait SqlDriver: Send + Sync + 'static { + async fn update_heartbeat(&self, service_name: &str, id: &str) -> MetaResult<()>; + + async fn try_campaign(&self, service_name: &str, id: &str, ttl: i64) + -> MetaResult; + async fn leader(&self, service_name: &str) -> MetaResult>; + + async fn candidates(&self, service_name: &str) -> MetaResult>; + + async fn resign(&self, service_name: &str, id: &str) -> MetaResult<()>; +} + +pub(crate) trait SqlDriverCommon { + const ELECTION_LEADER_TABLE_NAME: &'static str = "election_leader"; + const ELECTION_MEMBER_TABLE_NAME: &'static str = "election_members"; + + fn election_table_name() -> &'static str { + Self::ELECTION_LEADER_TABLE_NAME + } + fn member_table_name() -> &'static str { + Self::ELECTION_MEMBER_TABLE_NAME + } +} + +impl SqlDriverCommon for MySqlDriver {} + +impl SqlDriverCommon for PostgresDriver {} + +impl SqlDriverCommon for SqliteDriver {} + +pub struct MySqlDriver { + pool: MySqlPool, +} + +pub struct PostgresDriver { + pool: PgPool, +} + +pub struct SqliteDriver { + pool: SqlitePool, +} + +#[async_trait::async_trait] +impl SqlDriver for SqliteDriver { + async fn update_heartbeat(&self, service_name: &str, id: &str) -> MetaResult<()> { + sqlx::query(&format!( + r#"INSERT INTO {table} (id, service, last_heartbeat) +VALUES($1, $2, CURRENT_TIMESTAMP) +ON CONFLICT (id, service) +DO + UPDATE SET last_heartbeat = EXCLUDED.last_heartbeat; +"#, + table = Self::member_table_name() + )) + .bind(id) + .bind(service_name) + .execute(&self.pool) + .await?; + + Ok(()) + } + + async fn try_campaign( + &self, + service_name: &str, + id: &str, + ttl: i64, + ) -> MetaResult { + let row = sqlx::query_as::(&format!( + r#"INSERT INTO {table} (service, id, last_heartbeat) +VALUES ($1, $2, CURRENT_TIMESTAMP) +ON CONFLICT (service) + DO UPDATE + SET id = CASE + WHEN DATETIME({table}.last_heartbeat, '+' || $3 || ' second') < CURRENT_TIMESTAMP THEN EXCLUDED.id + ELSE {table}.id + END, + last_heartbeat = CASE + WHEN DATETIME({table}.last_heartbeat, '+' || $3 || ' seconds') < CURRENT_TIMESTAMP THEN EXCLUDED.last_heartbeat + WHEN {table}.id = EXCLUDED.id THEN EXCLUDED.last_heartbeat + ELSE {table}.last_heartbeat + END +RETURNING service, id, last_heartbeat; +"#, + table = Self::election_table_name() + )) + .bind(service_name) + .bind(id) + .bind(ttl) + .fetch_one(&self.pool) + .await?; + + Ok(row) + } + + async fn leader(&self, service_name: &str) -> MetaResult> { + let row = sqlx::query_as::<_, ElectionRow>(&format!( + r#"SELECT service, id, last_heartbeat FROM {table} WHERE service = $1;"#, + table = Self::election_table_name() + )) + .bind(service_name) + .fetch_optional(&self.pool) + .await?; + + Ok(row) + } + + async fn candidates(&self, service_name: &str) -> MetaResult> { + let row = sqlx::query_as::<_, ElectionRow>(&format!( + r#"SELECT service, id, last_heartbeat FROM {table} WHERE service = $1;"#, + table = Self::member_table_name() + )) + .bind(service_name) + .fetch_all(&self.pool) + .await?; + + Ok(row) + } + + async fn resign(&self, service_name: &str, id: &str) -> MetaResult<()> { + let mut txn = self.pool.begin().await?; + sqlx::query(&format!( + r#" + DELETE FROM {table} WHERE service = $1 AND id = $2; + "#, + table = Self::election_table_name() + )) + .bind(service_name) + .bind(id) + .execute(&mut *txn) + .await?; + + sqlx::query(&format!( + r#" + DELETE FROM {table} WHERE service = $1 AND id = $2; + "#, + table = Self::member_table_name() + )) + .bind(service_name) + .bind(id) + .execute(&mut *txn) + .await?; + + txn.commit().await?; + + Ok(()) + } +} + +#[async_trait::async_trait] +impl SqlDriver for MySqlDriver { + async fn update_heartbeat(&self, service_name: &str, id: &str) -> MetaResult<()> { + sqlx::query(&format!( + r#"INSERT INTO {table} (id, service, last_heartbeat) +VALUES(?, ?, NOW()) +ON duplicate KEY + UPDATE last_heartbeat = VALUES(last_heartbeat); +"#, + table = Self::member_table_name() + )) + .bind(id) + .bind(service_name) + .execute(&self.pool) + .await?; + + Ok(()) + } + + async fn try_campaign( + &self, + service_name: &str, + id: &str, + ttl: i64, + ) -> MetaResult { + let _ = sqlx::query::(&format!( + r#"INSERT + IGNORE +INTO {table} (service, id, last_heartbeat) +VALUES (?, ?, NOW()) +ON duplicate KEY + UPDATE id = if(last_heartbeat < NOW() - INTERVAL ? SECOND, + VALUES(id), id), + last_heartbeat = if(id = + VALUES(id), + VALUES(last_heartbeat), last_heartbeat);"#, + table = Self::election_table_name() + )) + .bind(service_name) + .bind(id) + .bind(ttl) + .execute(&self.pool) + .await?; + + let row = sqlx::query_as::(&format!( + r#"SELECT service, id, last_heartbeat FROM {table} WHERE service = ?;"#, + table = Self::election_table_name(), + )) + .bind(service_name) + .fetch_one(&self.pool) + .await?; + + Ok(row) + } + + async fn leader(&self, service_name: &str) -> MetaResult> { + let row = sqlx::query_as::(&format!( + r#"SELECT service, id, last_heartbeat FROM {table} WHERE service = ?;"#, + table = Self::election_table_name() + )) + .bind(service_name) + .fetch_optional(&self.pool) + .await?; + + Ok(row) + } + + async fn candidates(&self, service_name: &str) -> MetaResult> { + let row = sqlx::query_as::(&format!( + r#"SELECT service, id, last_heartbeat FROM {table} WHERE service = ?;"#, + table = Self::member_table_name() + )) + .bind(service_name) + .fetch_all(&self.pool) + .await?; + + Ok(row) + } + + async fn resign(&self, service_name: &str, id: &str) -> MetaResult<()> { + let mut txn = self.pool.begin().await?; + sqlx::query(&format!( + r#" + DELETE FROM {table} WHERE service = ? AND id = ?; + "#, + table = Self::election_table_name() + )) + .bind(service_name) + .bind(id) + .execute(&mut *txn) + .await?; + + sqlx::query(&format!( + r#" + DELETE FROM {table} WHERE service = ? AND id = ?; + "#, + table = Self::member_table_name() + )) + .bind(service_name) + .bind(id) + .execute(&mut *txn) + .await?; + + txn.commit().await?; + + Ok(()) + } +} + +#[async_trait::async_trait] +impl SqlDriver for PostgresDriver { + async fn update_heartbeat(&self, service_name: &str, id: &str) -> MetaResult<()> { + sqlx::query(&format!( + r#"INSERT INTO {table} (id, service, last_heartbeat) +VALUES($1, $2, NOW()) +ON CONFLICT (id, service) +DO + UPDATE SET last_heartbeat = EXCLUDED.last_heartbeat; +"#, + table = Self::member_table_name() + )) + .bind(id) + .bind(service_name) + .execute(&self.pool) + .await?; + + Ok(()) + } + + async fn try_campaign( + &self, + service_name: &str, + id: &str, + ttl: i64, + ) -> MetaResult { + let row = sqlx::query_as::(&format!( + r#"INSERT INTO {table} (service, id, last_heartbeat) +VALUES ($1, $2, NOW()) +ON CONFLICT (service) + DO UPDATE + SET id = CASE + WHEN {table}.last_heartbeat < NOW() - $3::INTERVAL THEN EXCLUDED.id + ELSE {table}.id + END, + last_heartbeat = CASE + WHEN {table}.last_heartbeat < NOW() - $3::INTERVAL THEN EXCLUDED.last_heartbeat + WHEN {table}.id = EXCLUDED.id THEN EXCLUDED.last_heartbeat + ELSE {table}.last_heartbeat + END +RETURNING service, id, last_heartbeat; +"#, + table = Self::election_table_name() + )) + .bind(service_name) + .bind(id) + .bind(Duration::from_secs(ttl as u64)) + .fetch_one(&self.pool) + .await?; + + Ok(row) + } + + async fn leader(&self, service_name: &str) -> MetaResult> { + let row = sqlx::query_as::(&format!( + r#"SELECT service, id, last_heartbeat FROM {table} WHERE service = $1;"#, + table = Self::election_table_name() + )) + .bind(service_name) + .fetch_optional(&self.pool) + .await?; + + Ok(row) + } + + async fn candidates(&self, service_name: &str) -> MetaResult> { + let row = sqlx::query_as::(&format!( + r#"SELECT service, id, last_heartbeat FROM {table} WHERE service = $1;"#, + table = Self::member_table_name() + )) + .bind(service_name) + .fetch_all(&self.pool) + .await?; + + Ok(row) + } + + async fn resign(&self, service_name: &str, id: &str) -> MetaResult<()> { + let mut txn = self.pool.begin().await?; + sqlx::query(&format!( + r#" + DELETE FROM {table} WHERE service = $1 AND id = $2; + "#, + table = Self::election_table_name() + )) + .bind(service_name) + .bind(id) + .execute(&mut *txn) + .await?; + + sqlx::query(&format!( + r#" + DELETE FROM {table} WHERE service = $1 AND id = $2; + "#, + table = Self::member_table_name() + )) + .bind(service_name) + .bind(id) + .execute(&mut *txn) + .await?; + + txn.commit().await?; + + Ok(()) + } +} + +#[async_trait::async_trait] +impl ElectionClient for SqlBackendElectionClient +where + T: SqlDriver + Send + Sync + 'static, +{ + fn id(&self) -> MetaResult { + Ok(self.id.clone()) + } + + async fn run_once(&self, ttl: i64, stop: Receiver<()>) -> MetaResult<()> { + let stop = stop.clone(); + + let member_refresh_driver = self.driver.clone(); + + let id = self.id.clone(); + + let mut member_refresh_stop = stop.clone(); + + let handle = tokio::spawn(async move { + let mut ticker = tokio::time::interval(Duration::from_secs(1)); + + loop { + tokio::select! { + _ = ticker.tick() => { + + if let Err(e) = member_refresh_driver + .update_heartbeat(META_ELECTION_KEY, id.as_str()) + .await { + + tracing::debug!("keep alive for member {} failed {}", id, e); + continue + } + } + _ = member_refresh_stop.changed() => { + return; + } + } + } + }); + + let _guard = scopeguard::guard(handle, |handle| handle.abort()); + + self.is_leader_sender.send_replace(false); + + let mut timeout_ticker = time::interval(Duration::from_secs_f64(ttl as f64 / 2.0)); + timeout_ticker.reset(); + let mut stop = stop.clone(); + + let mut is_leader = false; + + let mut election_ticker = time::interval(Duration::from_secs(1)); + + loop { + tokio::select! { + _ = election_ticker.tick() => { + let election_row = self + .driver + .try_campaign(META_ELECTION_KEY, self.id.as_str(), ttl) + .await?; + + assert_eq!(election_row.service, META_ELECTION_KEY); + + if election_row.id.eq_ignore_ascii_case(self.id.as_str()) { + if !is_leader{ + self.is_leader_sender.send_replace(true); + is_leader = true; + } + } else if is_leader { + tracing::warn!("leader has been changed to {}", election_row.id); + break; + } + + timeout_ticker.reset(); + } + _ = timeout_ticker.tick() => { + tracing::error!("member {} election timeout", self.id); + break; + } + _ = stop.changed() => { + tracing::info!("stop signal received when observing"); + + if is_leader { + tracing::info!("leader {} resigning", self.id); + if let Err(e) = self.driver.resign(META_ELECTION_KEY, self.id.as_str()).await { + tracing::warn!("resign failed {}", e); + } + } + + return Ok(()); + } + } + } + self.is_leader_sender.send_replace(false); + + return Ok(()); + } + + fn subscribe(&self) -> Receiver { + self.is_leader_sender.subscribe() + } + + async fn leader(&self) -> MetaResult> { + let row = self.driver.leader(META_ELECTION_KEY).await?; + Ok(row.map(|row| ElectionMember { + id: row.id, + is_leader: true, + })) + } + + async fn get_members(&self) -> MetaResult> { + let leader = self.leader().await?; + let members = self.driver.candidates(META_ELECTION_KEY).await?; + + Ok(members + .into_iter() + .map(|row| { + let is_leader = leader + .as_ref() + .map(|leader| leader.id.eq_ignore_ascii_case(row.id.as_str())) + .unwrap_or(false); + + ElectionMember { + id: row.id, + is_leader, + } + }) + .collect()) + } + + async fn is_leader(&self) -> bool { + *self.is_leader_sender.borrow() + } +} + +#[cfg(not(madsim))] +#[cfg(test)] +mod tests { + use std::sync::Arc; + + use sqlx::sqlite::SqlitePoolOptions; + use sqlx::SqlitePool; + use tokio::sync::watch; + + use crate::rpc::election::sql::{SqlBackendElectionClient, SqlDriverCommon, SqliteDriver}; + use crate::{ElectionClient, MetaResult}; + + async fn prepare_sqlite_env() -> MetaResult { + let pool = SqlitePoolOptions::new().connect("sqlite::memory:").await?; + let _ = sqlx::query( + &format!("CREATE TABLE {table} (service VARCHAR(256) PRIMARY KEY, id VARCHAR(256), last_heartbeat DATETIME)", + table = SqliteDriver::election_table_name())) + .execute(&pool).await?; + + let _ = sqlx::query( + &format!("CREATE TABLE {table} (service VARCHAR(256), id VARCHAR(256), last_heartbeat DATETIME, PRIMARY KEY (service, id))", + table = SqliteDriver::member_table_name())) + .execute(&pool).await?; + + Ok(pool) + } + + #[tokio::test] + async fn test_sql_election() { + let id = "test_id".to_string(); + let pool = prepare_sqlite_env().await.unwrap(); + + let provider = SqliteDriver { pool }; + let (sender, _) = watch::channel(false); + let sql_election_client: Arc = Arc::new(SqlBackendElectionClient { + id, + driver: Arc::new(provider), + is_leader_sender: sender, + }); + let (stop_sender, _) = watch::channel(()); + + let stop_receiver = stop_sender.subscribe(); + + let mut receiver = sql_election_client.subscribe(); + let client_ = sql_election_client.clone(); + tokio::spawn(async move { client_.run_once(10, stop_receiver).await.unwrap() }); + + loop { + receiver.changed().await.unwrap(); + if *receiver.borrow() { + assert!(sql_election_client.is_leader().await); + break; + } + } + } + + #[tokio::test] + async fn test_sql_election_multi() { + let (stop_sender, _) = watch::channel(()); + + let mut clients = vec![]; + + let pool = prepare_sqlite_env().await.unwrap(); + for i in 1..3 { + let id = format!("test_id_{}", i); + let provider = SqliteDriver { pool: pool.clone() }; + let (sender, _) = watch::channel(false); + let sql_election_client: Arc = Arc::new(SqlBackendElectionClient { + id, + driver: Arc::new(provider), + is_leader_sender: sender, + }); + + let stop_receiver = stop_sender.subscribe(); + let client_ = sql_election_client.clone(); + tokio::spawn(async move { client_.run_once(10, stop_receiver).await.unwrap() }); + clients.push(sql_election_client); + } + + let mut is_leaders = vec![]; + + for client in clients { + is_leaders.push(client.is_leader().await); + } + + assert!(is_leaders.iter().filter(|&x| *x).count() <= 1); + } +} diff --git a/src/meta/src/rpc/mod.rs b/src/meta/src/rpc/mod.rs index 6baa080fba83b..36380c4d2dafb 100644 --- a/src/meta/src/rpc/mod.rs +++ b/src/meta/src/rpc/mod.rs @@ -14,13 +14,14 @@ mod cloud_provider; pub mod ddl_controller; -mod election_client; +pub mod election; mod intercept; pub mod metrics; pub mod server; pub mod service; -pub use election_client::{ElectionClient, ElectionMember, EtcdElectionClient}; +pub use election::etcd::EtcdElectionClient; +pub use election::{ElectionClient, ElectionMember}; pub use service::cluster_service::ClusterServiceImpl; pub use service::ddl_service::DdlServiceImpl; pub use service::heartbeat_service::HeartbeatServiceImpl; diff --git a/src/meta/src/rpc/server.rs b/src/meta/src/rpc/server.rs index 53000dee54f40..6a8726b8a1695 100644 --- a/src/meta/src/rpc/server.rs +++ b/src/meta/src/rpc/server.rs @@ -64,7 +64,8 @@ use crate::manager::{ SystemParamsManager, }; use crate::rpc::cloud_provider::AwsEc2Client; -use crate::rpc::election_client::{ElectionClient, EtcdElectionClient}; +use crate::rpc::election::etcd::EtcdElectionClient; +use crate::rpc::election::ElectionClient; use crate::rpc::metrics::{ start_fragment_info_monitor, start_worker_info_monitor, GLOBAL_META_METRICS, }; diff --git a/src/workspace-hack/Cargo.toml b/src/workspace-hack/Cargo.toml index 4f60cf6c03f92..49ede1b4ab9a7 100644 --- a/src/workspace-hack/Cargo.toml +++ b/src/workspace-hack/Cargo.toml @@ -19,22 +19,26 @@ publish = false ### BEGIN HAKARI SECTION [dependencies] ahash = { version = "0.8" } +allocator-api2 = { version = "0.2", default-features = false, features = ["alloc", "nightly"] } anyhow = { version = "1", features = ["backtrace"] } aws-credential-types = { version = "0.55", default-features = false, features = ["hardcoded-credentials"] } aws-sdk-s3 = { version = "0.28", features = ["native-tls"] } aws-smithy-client = { version = "0.55", default-features = false, features = ["native-tls", "rustls"] } base64 = { version = "0.21", features = ["alloc"] } bit-vec = { version = "0.6" } -bitflags = { version = "2", default-features = false, features = ["std"] } +bitflags = { version = "2", default-features = false, features = ["serde", "std"] } +byteorder = { version = "1" } bytes = { version = "1", features = ["serde"] } chrono = { version = "0.4", features = ["alloc", "serde"] } clap = { version = "4", features = ["cargo", "derive", "env"] } clap_builder = { version = "4", default-features = false, features = ["cargo", "color", "env", "help", "std", "suggestions", "usage"] } combine = { version = "4" } crossbeam-epoch = { version = "0.9" } +crossbeam-queue = { version = "0.3" } crossbeam-utils = { version = "0.8" } deranged = { version = "0.3", default-features = false, features = ["serde", "std"] } -either = { version = "1" } +digest = { version = "0.10", features = ["mac", "oid", "std"] } +either = { version = "1", features = ["serde"] } fail = { version = "0.5", default-features = false, features = ["failpoints"] } fixedbitset = { version = "0.4" } flate2 = { version = "1", features = ["zlib"] } @@ -48,10 +52,12 @@ futures-task = { version = "0.3" } futures-util = { version = "0.3", features = ["channel", "io", "sink"] } hashbrown-582f2526e08bb6a0 = { package = "hashbrown", version = "0.14", features = ["nightly", "raw"] } hashbrown-5ef9efb8ec2df382 = { package = "hashbrown", version = "0.12", features = ["nightly", "raw"] } +heck = { version = "0.4", features = ["unicode"] } hyper = { version = "0.14", features = ["full"] } indexmap = { version = "1", default-features = false, features = ["std"] } itertools = { version = "0.10" } jni = { version = "0.21", features = ["invocation"] } +lazy_static = { version = "1", default-features = false, features = ["spin_no_std"] } lexical-core = { version = "0.8", features = ["format"] } lexical-parse-float = { version = "0.8", default-features = false, features = ["format", "std"] } lexical-parse-integer = { version = "0.8", default-features = false, features = ["format", "std"] } @@ -63,11 +69,13 @@ lock_api = { version = "0.4", features = ["arc_lock"] } log = { version = "0.4", default-features = false, features = ["std"] } madsim-rdkafka = { git = "https://github.com/madsim-rs/madsim.git", rev = "fedb1e3", features = ["cmake-build", "gssapi", "ssl-vendored", "zstd"] } madsim-tokio = { version = "0.2", default-features = false, features = ["fs", "io-util", "macros", "net", "process", "rt", "rt-multi-thread", "signal", "sync", "time", "tracing"] } +md-5 = { version = "0.10" } mio = { version = "0.8", features = ["net", "os-ext"] } multimap = { version = "0.8" } nom = { version = "7" } num-bigint = { version = "0.4" } num-integer = { version = "0.1", features = ["i128"] } +num-iter = { version = "0.1", default-features = false, features = ["i128", "std"] } num-traits = { version = "0.2", features = ["i128", "libm"] } opentelemetry_api = { version = "0.20", features = ["logs", "metrics"] } opentelemetry_sdk = { version = "0.20", features = ["logs", "metrics"] } @@ -90,9 +98,17 @@ ring = { version = "0.16", features = ["std"] } rust_decimal = { version = "1", features = ["db-postgres", "maths"] } scopeguard = { version = "1" } serde = { version = "1", features = ["alloc", "derive", "rc"] } -serde_json = { version = "1", features = ["alloc"] } +serde_json = { version = "1", features = ["alloc", "raw_value"] } serde_with = { version = "3", features = ["json"] } +sha1 = { version = "0.10" } +sha2 = { version = "0.10" } +signature = { version = "2", default-features = false, features = ["digest", "rand_core", "std"] } smallvec = { version = "1", default-features = false, features = ["serde", "union", "write"] } +socket2 = { version = "0.5", default-features = false, features = ["all"] } +sqlx-core = { version = "0.7", features = ["_rt-tokio", "any", "chrono", "json", "migrate", "offline"] } +sqlx-mysql = { version = "0.7", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } +sqlx-postgres = { version = "0.7", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } +sqlx-sqlite = { version = "0.7", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } subtle = { version = "2" } time = { version = "0.3", features = ["local-offset", "macros", "serde-well-known"] } tinyvec = { version = "1", features = ["alloc", "grab_spare_slice", "rustc_1_55"] } @@ -111,27 +127,50 @@ unicode-bidi = { version = "0.3" } unicode-normalization = { version = "0.1" } url = { version = "2", features = ["serde"] } uuid = { version = "1", features = ["fast-rng", "serde", "v4"] } +whoami = { version = "1" } [build-dependencies] ahash = { version = "0.8" } +allocator-api2 = { version = "0.2", default-features = false, features = ["alloc", "nightly"] } anyhow = { version = "1", features = ["backtrace"] } auto_enums = { version = "0.8", features = ["futures03"] } -bitflags = { version = "2", default-features = false, features = ["std"] } +base64 = { version = "0.21", features = ["alloc"] } +bitflags = { version = "2", default-features = false, features = ["serde", "std"] } +byteorder = { version = "1" } bytes = { version = "1", features = ["serde"] } cc = { version = "1", default-features = false, features = ["parallel"] } +chrono = { version = "0.4", features = ["alloc", "serde"] } +crossbeam-queue = { version = "0.3" } +crossbeam-utils = { version = "0.8" } deranged = { version = "0.3", default-features = false, features = ["serde", "std"] } -either = { version = "1" } +digest = { version = "0.10", features = ["mac", "oid", "std"] } +either = { version = "1", features = ["serde"] } fixedbitset = { version = "0.4" } frunk_core = { version = "0.4", default-features = false, features = ["std"] } +futures-channel = { version = "0.3", features = ["sink"] } +futures-core = { version = "0.3" } +futures-io = { version = "0.3" } +futures-sink = { version = "0.3" } +futures-task = { version = "0.3" } +futures-util = { version = "0.3", features = ["channel", "io", "sink"] } hashbrown-582f2526e08bb6a0 = { package = "hashbrown", version = "0.14", features = ["nightly", "raw"] } +heck = { version = "0.4", features = ["unicode"] } itertools = { version = "0.10" } +lazy_static = { version = "1", default-features = false, features = ["spin_no_std"] } libc = { version = "0.2", features = ["extra_traits"] } +lock_api = { version = "0.4", features = ["arc_lock"] } log = { version = "0.4", default-features = false, features = ["std"] } +madsim-tokio = { version = "0.2", default-features = false, features = ["fs", "io-util", "macros", "net", "process", "rt", "rt-multi-thread", "signal", "sync", "time", "tracing"] } +md-5 = { version = "0.10" } +mio = { version = "0.8", features = ["net", "os-ext"] } multimap = { version = "0.8" } nom = { version = "7" } num-bigint = { version = "0.4" } num-integer = { version = "0.1", features = ["i128"] } +num-iter = { version = "0.1", default-features = false, features = ["i128", "std"] } num-traits = { version = "0.2", features = ["i128", "libm"] } +parking_lot = { version = "0.12", features = ["arc_lock", "deadlock_detection"] } +parking_lot_core = { version = "0.9", default-features = false, features = ["deadlock_detection"] } petgraph = { version = "0.6" } phf = { version = "0.11", features = ["uncased"] } phf_shared = { version = "0.11", features = ["uncased"] } @@ -143,13 +182,32 @@ rand_core = { version = "0.6", default-features = false, features = ["std"] } regex = { version = "1" } regex-automata = { version = "0.3", default-features = false, features = ["dfa-onepass", "hybrid", "meta", "nfa-backtrack", "perf-inline", "perf-literal", "unicode"] } regex-syntax = { version = "0.7" } +scopeguard = { version = "1" } serde = { version = "1", features = ["alloc", "derive", "rc"] } -serde_json = { version = "1", features = ["alloc"] } +serde_json = { version = "1", features = ["alloc", "raw_value"] } +sha1 = { version = "0.10" } +sha2 = { version = "0.10" } +signature = { version = "2", default-features = false, features = ["digest", "rand_core", "std"] } +smallvec = { version = "1", default-features = false, features = ["serde", "union", "write"] } +sqlx-core = { version = "0.7", features = ["_rt-tokio", "any", "chrono", "json", "migrate", "offline"] } +sqlx-mysql = { version = "0.7", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } +sqlx-postgres = { version = "0.7", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } +sqlx-sqlite = { version = "0.7", default-features = false, features = ["any", "chrono", "json", "migrate", "offline"] } +subtle = { version = "2" } syn-dff4ba8e3ae991db = { package = "syn", version = "1", features = ["extra-traits", "full", "visit", "visit-mut"] } syn-f595c2ba2a3f28df = { package = "syn", version = "2", features = ["extra-traits", "fold", "full", "visit", "visit-mut"] } time = { version = "0.3", features = ["local-offset", "macros", "serde-well-known"] } time-macros = { version = "0.2", default-features = false, features = ["formatting", "parsing", "serde"] } +tinyvec = { version = "1", features = ["alloc", "grab_spare_slice", "rustc_1_55"] } +tokio = { version = "1", features = ["full", "stats", "tracing"] } +tokio-stream = { git = "https://github.com/madsim-rs/tokio.git", rev = "fe39bb8e", features = ["fs", "net"] } toml_datetime = { version = "0.6", default-features = false, features = ["serde"] } toml_edit = { version = "0.19", features = ["serde"] } +tracing = { version = "0.1", features = ["log"] } +tracing-core = { version = "0.1" } +unicode-bidi = { version = "0.3" } +unicode-normalization = { version = "0.1" } +url = { version = "2", features = ["serde"] } +whoami = { version = "1" } ### END HAKARI SECTION