Commit Graph

1999 Commits

Author SHA1 Message Date
c438fcbafd storage/backend: fatal if there is panic during defrag
We should exit as soon as possible if there is panic during defrag.
Because that tx might be closed. The inflight request might use invalid
tx and then panic as well. However, the real panic might be shadowed by
new panic. It's related to goroutine schedule. So, we should fatal here.

How to reproduce bbolt#715:

```diff
diff --git a/server/etcdserver/api/v3rpc/maintenance.go b/server/etcdserver/api/v3rpc/maintenance.go
index 4f55c7c74..0a91b4225 100644
--- a/server/etcdserver/api/v3rpc/maintenance.go
+++ b/server/etcdserver/api/v3rpc/maintenance.go
@@ -89,7 +89,13 @@ func NewMaintenanceServer(s *etcdserver.EtcdServer, healthNotifier notifier) pb.
 func (ms *maintenanceServer) Defragment(ctx context.Context, sr *pb.DefragmentRequest) (*pb.DefragmentResponse, error) {
        ms.lg.Info("starting defragment")
        ms.healthNotifier.defragStarted()
-       defer ms.healthNotifier.defragFinished()
+       defer func() {
+               ms.healthNotifier.defragFinished()
+               if rerr := recover(); rerr != nil {
+                       time.Sleep(30 * time.Second)
+                       panic(rerr)
+               }
+       }()
        err := ms.bg.Backend().Defrag()
        if err != nil {
                ms.lg.Warn("failed to defragment", zap.Error(err))
```

```bash
$ make gofail-enable
$ make
$ GOFAIL_HTTP="127.0.0.1:1234" bin/etcd

$ New Terminal
$ curl http://127.0.0.1:1234/defragBeforeRename -XPUT -d'panic()'
$ bin/etcdctl defrag

$ Old Terminal
{"level":"info","ts":"2024-04-09T23:28:54.084434+0800","caller":"v3rpc/maintenance.go:90","msg":"starting defragment"}
{"level":"info","ts":"2024-04-09T23:28:54.087363+0800","caller":"backend/backend.go:509","msg":"defragmenting","path":"default.etcd/member/snap/db","current-db-size-bytes":20480,"current-db-size":"20 kB","current-db-size-in-use-bytes":16384,"current-db-size-in-use":"16 kB"}
{"level":"info","ts":"2024-04-09T23:28:54.091229+0800","caller":"v3rpc/health.go:62","msg":"grpc service status changed","service":"","status":"SERVING"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xbb2553]

goroutine 156 [running]:
go.etcd.io/bbolt.(*Tx).Bucket(...)
        go.etcd.io/bbolt@v1.4.0-alpha.0/tx.go:112
go.etcd.io/etcd/server/v3/storage/backend.(*baseReadTx).UnsafeRange(0xc00061ac80, {0x12b7780, 0x1a73420}, {0x1a113e8, 0xe, 0xe}, {0x0, 0x0, 0x0}, 0x1)
        go.etcd.io/etcd/server/v3/storage/backend/read_tx.go:103 +0x233
go.etcd.io/etcd/server/v3/storage/schema.UnsafeReadStorageVersion({0x7f6280613618?, 0xc00061ac80?})
        go.etcd.io/etcd/server/v3/storage/schema/version.go:35 +0x5d
go.etcd.io/etcd/server/v3/storage/schema.UnsafeDetectSchemaVersion(0xc000334b80, {0x7f6280613618, 0xc00061ac80})
        go.etcd.io/etcd/server/v3/storage/schema/schema.go:94 +0x47
go.etcd.io/etcd/server/v3/storage/schema.DetectSchemaVersion(0xc000334b80, {0x12b77f0, 0xc00061ac80})
        go.etcd.io/etcd/server/v3/storage/schema/schema.go:89 +0xf2
go.etcd.io/etcd/server/v3/etcdserver.(*EtcdServer).StorageVersion(0xc000393c08)
        go.etcd.io/etcd/server/v3/etcdserver/server.go:2216 +0x105
go.etcd.io/etcd/server/v3/etcdserver.(*serverVersionAdapter).GetStorageVersion(0x0?)
        go.etcd.io/etcd/server/v3/etcdserver/adapters.go:77 +0x16
go.etcd.io/etcd/server/v3/etcdserver/version.(*Monitor).UpdateStorageVersionIfNeeded(0xc00002df70)
        go.etcd.io/etcd/server/v3/etcdserver/version/monitor.go:112 +0x5d
go.etcd.io/etcd/server/v3/etcdserver.(*EtcdServer).monitorStorageVersion(0xc000393c08)
        go.etcd.io/etcd/server/v3/etcdserver/server.go:2259 +0xa8
go.etcd.io/etcd/server/v3/etcdserver.(*EtcdServer).GoAttach.func1()
        go.etcd.io/etcd/server/v3/etcdserver/server.go:2440 +0x59
created by go.etcd.io/etcd/server/v3/etcdserver.(*EtcdServer).GoAttach in goroutine 1
        go.etcd.io/etcd/server/v3/etcdserver/server.go:2438 +0xf9
```

REF: https://github.com/etcd-io/bbolt/issues/715

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-11-06 23:56:54 +00:00
75274b24e2 Merge pull request #18840 from ArkaSaha30/deps_mgmt_4_11_24
[2024-11-04] Manual Dependency Bump
2024-11-06 17:30:55 +00:00
9250982e1a Merge pull request #18822 from ghouscht/issue-18810
fix(defrag): handle no space left error
2024-11-06 13:00:39 +00:00
04c042ceac fix(defrag): handle defragdb failure
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
2024-11-06 12:43:51 +01:00
35cab80e1f fix(defrag): handle no space left error
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
2024-11-06 11:01:17 +01:00
447bec1bf3 dependency: bump go.etcd.io/bbolt from 1.4.0-alpha.1 to 1.4.0-beta.0
This commit will bump dependency go.etcd.io/bbolt from 1.4.0-alpha.1 to 1.4.0-beta.0

Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>
2024-11-06 15:23:51 +05:30
f43c6815b1 dependency: bump github.com/grpc-ecosystem/grpc-gateway/v2 from 2.22.0 to 2.23.0
This commit will bump dependency github.com/grpc-ecosystem/grpc-gateway/v2 from 2.22.0 to 2.23.0

fixes genproto error as per: https://github.com/etcd-io/etcd/blob/main/Documentation/contributor-guide/dependency_management.md#troubleshooting

Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>
2024-11-06 15:23:08 +05:30
fed92fa7ff dependency: bump github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1
This commit will bump dependency github.com/golang-jwt/jwt/v4 from 4.5.0 to 4.5.1

Signed-off-by: ArkaSaha30 <arkasaha30@gmail.com>
2024-11-05 18:11:05 +05:30
4dbc7e943f Merge pull request #18814 from mmorel-35/testifylint/require-error
fix: enable require-error rule from testifylint
2024-11-03 19:57:10 +00:00
df15a7fe4c dependency: bump github.com/prometheus/common from 0.60.0 to 0.60.1
Reference:
- https://github.com/etcd-io/etcd/pull/18796

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-31 22:43:48 +08:00
5858a08f1b fix: enable require-error rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-31 08:33:34 +01:00
6883308899 Merge pull request #18800 from mmorel-35/testifylint/require-error
fix: enable require-error rule from testifylint in client, pkg and server packages
2024-10-30 23:03:01 +00:00
8ec90c6088 Merge pull request #18780 from mmorel-35/server/errorlint
fix: enable errorlint in server directory
2024-10-30 22:55:43 +00:00
694b0fbdb6 refactor Etcdserver.snapshot to extract compaction into a separate method
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-10-30 09:25:54 +00:00
3a3115122e fix: enable require-error rule from testifylint in client, pkg and server packages
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-28 21:02:58 +01:00
5cce245df5 dependency: bump github.com/prometheus/client_golang from 1.20.4 to 1.20.5
Reference:
- https://github.com/etcd-io/etcd/pull/18758

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-27 12:43:19 +09:00
3abdf612b3 fix: enable errorlint in server directory
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-26 08:16:47 +02:00
6d2b23224c Merge pull request #18739 from veshij/leak_fix
etcdserver: terminate recvLoop on serverWatchStream.close()
2024-10-24 11:29:43 +02:00
8a0fd66db3 Fix risk of a partial write txn being applied
Signed-off-by: Shyam Jeedigunta <jeedigv@amazon.com>
2024-10-22 12:32:33 -07:00
a7dcfdb839 Merge pull request #18741 from ghouscht/testifylint-formatter
fix: enable formatter rule from testifylint
2024-10-22 06:15:27 +01:00
77607356d9 [serverWatchStream] terminate recvLoop on sws.close()
Signed-off-by: Oleg Guba <oleg.guba@gmail.com>
2024-10-21 12:09:27 -07:00
8c538cd81c dependency: bump bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc from 1.30.0 to 1.31.0, github.com/rogpeppe/go-internal from v1.12.0 to v1.13.1, and google.golang.org/genproto/googleapis/api from v0.0.0-20240924160255-9d4c2d233b61 to v0.0.0-20241007155032-5fefd90f89a9
Also addressed inconsistent versions for dependency: github.com/rogpeppe/go-internal and google.golang.org/genproto/googleapis/api

Reference:
- https://github.com/etcd-io/etcd/pull/18736

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-20 13:37:57 +08:00
940777e201 dependency: bump google.golang.org/protobuf from 1.34.2 to 1.35.1 and google.golang.org/genproto/googleapis/rpc from v0.0.0-20240924160255-9d4c2d233b61 to v0.0.0-20241007155032-5fefd90f89a9
Also addressed inconsistent versions for dependency: google.golang.org/genproto/googleapis/rpc

Reference:
- https://github.com/etcd-io/etcd/pull/18729

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-20 13:37:57 +08:00
ee972bab8c dependency: bump go.opentelemetry.io/otel from 1.30.0 to 1.31.0 and bump go.opentelemetry.io/otel/trace from 1.30.0 to 1.31.0
Reference:
- https://github.com/etcd-io/etcd/pull/18732
- https://github.com/etcd-io/etcd/pull/18735

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-20 13:37:57 +08:00
894b618a8d dependency: bump google.golang.org/protobuf from 1.34.2 to 1.35.1
Reference:
- https://github.com/etcd-io/etcd/pull/18729

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-20 13:37:57 +08:00
522edd56b7 dependency: bump golang.org/x/net from 0.29.0 to 0.30.0
Reference:
- https://github.com/etcd-io/etcd/pull/18730

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-20 13:37:57 +08:00
d275172c4c dependency: bump golang.org/x/time from 0.6.0 to 0.7.0
Reference:
- https://github.com/etcd-io/etcd/pull/18738

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-20 13:37:57 +08:00
0bec6a8efc embed: fix typo client-listen-x to listen-client-x
Signed-off-by: mingqing <mingqing@henji.org>
2024-10-18 11:42:54 +08:00
ff4a8df3aa fix: enable formatter rule from testifylint
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
2024-10-17 14:10:35 +02:00
6165f60419 fix: enable expected-actual rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-17 09:17:59 +00:00
7ecb72a2b4 fix: enable error-nil rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-17 07:22:40 +02:00
f0187c38d1 Merge pull request #18689 from mmorel-35/testifylint/nil-compare
fix: enable nil-compare rule from testifylint
2024-10-11 09:41:28 +01:00
de2c95dcba fix: enable nil-compare rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-11 07:10:03 +02:00
33d7f2d53e fix: enable gofmt and whitespace linters
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-11 07:03:18 +02:00
e06fb81713 fix: enable empty and len rules from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-10 11:07:21 +00:00
36f0f659a2 dependency: bump golang.org/x/crypto from 0.27.0 to 0.28.0 and bump golang.org/x/text from 0.18.0 to 0.19.0
golang.org/x/text is bumped automatically alongside golang.org/x/crypto
as its dependency

Reference:
- https://github.com/etcd-io/etcd/pull/18692
- https://github.com/etcd-io/etcd/pull/18690

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-08 19:55:05 +02:00
3520d32235 dependency: bump github.com/prometheus/common from 0.59.1 to 0.60.0
Reference:
- https://github.com/etcd-io/etcd/pull/18691

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-08 19:55:05 +02:00
c256db1065 dependency: bump golang.org/x/sys from 0.25.0 to 0.26.0
Reference:
- https://github.com/etcd-io/etcd/pull/18693
- https://github.com/etcd-io/etcd/pull/18698

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-08 19:55:05 +02:00
f0d5967877 dependency: bump google.golang.org/grpc from 1.67.0 to 1.67.1
Reference:
- https://github.com/etcd-io/etcd/pull/18694

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-08 19:55:05 +02:00
b23947b604 fix: enable bool-compare rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-06 09:47:02 +02:00
08d54bc5a8 Remove context from appliers
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-10-04 18:14:25 +02:00
7537341861 Remove context from dispatch
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-10-04 16:56:16 +02:00
ffdf5f2d06 Remove context from top level apply
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-10-04 16:06:55 +02:00
073b968522 Merge pull request #18673 from henrybear327/dependencies/10_03_24
[2024-10-03] Bump dependency updates identified by dependabot
2024-10-04 12:07:22 +01:00
d012386222 Merge pull request #18606 from monogon-dev/fix-islearner-panic
etcdserver: fix panic when checking IsLearner of removed member
2024-10-04 10:50:12 +01:00
d1c83d1cfc dependency: bump go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc from 0.54.0 to 0.55.0
Reference:
- https://github.com/etcd-io/etcd/pull/18662

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-10-04 08:16:42 +02:00
c1976a6717 Merge pull request #18617 from redwrasse/redwrasse/server/remaining-errors-is
server: remaining errors.Is conversions
2024-10-03 14:47:01 +02:00
951fc964c5 Merge pull request #18668 from ghouscht/issue-17487
fix(v3compactor): flaky TestPeriodicSkipRevNotChange test by increasing timeout
2024-10-03 11:42:34 +02:00
4284a71a6c fix(v3compactor): flaky TestPeriodicSkipRevNotChange test by increasing timeout
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
2024-10-02 10:36:37 +00:00
8650df2868 Bump go version to 1.23.2
Signed-off-by: Agni <bhattacharyya.agni@gmail.com>
2024-10-02 03:34:11 +05:30