Skip to content

(AOE): lost data when restart because of GetSegmentedInfo failed during restart engine #483

Closed

Description

@sukki37

Can be reproduced ?

Yes

Steps:

  1. start db
  2. create table and insert some data (less than block size)
  3. ctrl-C
  4. restart db

Expected behavior:

The local engine returns the specific segmented index to adjust the raft init log index to recover all the data which have been inserted.

Actual behavior:

The local engine returns ErrNotFound, so we do not adjust the init index during the startup process and we cannot recover the inserted data which have not been sync to disk.

Environment:

  • Version or commit-id (e.g. v0.1.0 or 8b23a93):
  • Hardware parameters:
  • OS type:
  • Others:

Configuration file:

Additional context:

  • Error message from client:
  • Server log:
  • Other information:

Activity

  1. added
    kind/bug
    on Aug 24, 2021
  2. XuPeng-SH commented on Aug 24, 2021

    @XuPeng-SH
    Contributor

    Regarding the data replay after the restart, basically all the problems stem from the asynchronous flashing of the metadata of the data. Here's the possible root cause of this issue. When a new raft group is created, the dist aoe will commit a new table in distributed KV storage, and at the same time, a new table is created in the local AOE engine. Since the local engine flushes the meta and data asynchronously, if a crash happened before the flushing, there will be no record of the new table in the local engine during restart.
    This is a design problem, the solution needs to be explored

  3. sukki37 commented on Aug 24, 2021

    @sukki37
    ContributorAuthor

    Add logs

    2021/08/24 19:51:27.069 +08:00  DEBUG   db.go:277       Call local GetSegmentedId by MTPrefix, pattern is {"Matchers":[{"Type":0,"Pattern":"\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0005"}]}, metaInfo is {"Tables":{"1":{"ID":1,"CreatedOn":1629805863664591,"UpdatedOn":0,"DeltetedOn":0,"CreatedIndex":7,"DeletedIndex":0,"AppliedIndex":0}},"CheckPoint":1,"CkpTime":1629805863664600}, tbls is [Tbl(1) 0[]]
    2021/08/24 19:51:27.069 +08:00  ERROR   db.go:285       Call local GetSegmentedId, get segmented index failed, data is <Table[1]>(SegCnt=0)(Refs=2), err is <nil>
    matrixone/pkg/logutil.Errorf
            /Users/maomao/code/matrixone/pkg/logutil/global.go:53
    matrixone/pkg/vm/engine/aoe/storage/db.(*DB).GetSegmentedId
            /Users/maomao/code/matrixone/pkg/vm/engine/aoe/storage/db/db.go:285
    matrixone/pkg/vm/engine/aoe/dist.NewCubeDriverWithFactory.func8.1
            /Users/maomao/code/matrixone/pkg/vm/engine/aoe/dist/cube_driver.go:231
    github.com/matrixorigin/matrixcube/raftstore.getRaftConfig
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/raftstore/peer_replica.go:549
    github.com/matrixorigin/matrixcube/raftstore.newPeerReplica
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/raftstore/peer_replica.go:207
    github.com/matrixorigin/matrixcube/raftstore.createPeerReplica
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/raftstore/peer_replica.go:159
    github.com/matrixorigin/matrixcube/raftstore.(*store).startShards.func1
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/raftstore/store.go:490
    github.com/matrixorigin/matrixcube/storage/pebble.(*Storage).Scan
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/storage/pebble/storage.go:181
    github.com/matrixorigin/matrixcube/raftstore.(*store).startShards
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/raftstore/store.go:463
    github.com/matrixorigin/matrixcube/raftstore.(*store).Start
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/raftstore/store.go:181
    github.com/matrixorigin/matrixcube/server.(*Application).Start
            /Users/maomao/go/pkg/mod/github.com/matrixorigin/[email protected]/server/server.go:76
    matrixone/pkg/vm/engine/aoe/dist.(*driver).Start
            /Users/maomao/code/matrixone/pkg/vm/engine/aoe/dist/cube_driver.go:279
    main.main
            /Users/maomao/code/matrixone/cmd/db-server/main.go:178
    runtime.main
            /usr/local/go/src/runtime/proc.go:225
    2021/08/24 19:51:27.069 +08:00  DEBUG   cube_driver.go:225      InitAppliedIndex of [1]shard-5 is adjusted from 8 to 0
    2021/08/24 19:51:27.069568 [info] [raftstore]: shard 5 change init applied index from 8 to 8
    
    
  4. XuPeng-SH commented on Aug 24, 2021

    @XuPeng-SH
    Contributor

    There is a logic bug. The index of the create table is not counted as a segmented index.

  5. XuPeng-SH commented on Aug 24, 2021

    @XuPeng-SH
    Contributor

    fixed by #490

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions