Skip to content

Crash in unit tests #2393

@JaySon-Huang

Description

@JaySon-Huang

In #2356, we assume that page_files are not empty. However, unit tests randomly crash after that.

  1. A global RegionPersister created with path "./tmp/kvstore" and register a GC task on BackgroundService
  2. Before some unit test of the storage layer run, they would clean up old files on disk. However, we directly remove the whole "./tmp" for convenience in some tests.
  3. The GC task of RegionPersister run, find out that there are no page files on "./tmp/kvstore", and the unit test crash.

To fix this problem

  1. Add check for PageStorage::gc to avoid crash Add length check while running PageStorage GC #2394
  2. Refine the unit tests that remove the whole "./tmp" @jiaqizho

For the second task:

One of those tests is the Segment_test
https://github.com/pingcap/tics/blob/9f03c0570c337cbc1d7d72fee8680e84231d8e9d/dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment.cpp#L43-L48

The real paths of this test is generated by the StoragePathPool object (for multi-disk deployment)
https://github.com/pingcap/tics/blob/9f03c0570c337cbc1d7d72fee8680e84231d8e9d/dbms/src/Storages/DeltaMerge/tests/gtest_dm_segment.cpp#L71-L73

We should find a more elegant way to clean up old files for unit tests, instead of removing "./tmp" brutally. Hope that there would be no overlap between different test suite.
For example, each test case under the test suite Segment_test store its data under "./tmp/Segment_test" while each test case under the test suite Segment_test_2 store its data under "./tmp/Segment_Common_Handle_test". Before running each test case for Segment_test, it only removes the old files under "./tmp/Segment_test".

(After that, we can run different test suites parallelly one day. not included by this issue).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions