Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): improve database stability after power loss #3304

Merged
merged 33 commits into from
May 15, 2023
Merged

Conversation

bluestreak01
Copy link
Member

@bluestreak01 bluestreak01 commented May 4, 2023

Fixes #3276
Fixes #3050
Fixes #2420

Reviewed using msync/fsync and refactored codebase to ensure database recovers data after abrupt power loss.

Method of testing is as follows:

  • find a good USB stick or memory card, with decent thruput
  • run QuestDB against database on memory card
  • I used TSBS benchmark to upload data
  • pull the card/UBS stick out of the computer mid data upload
  • tested with customised loadTest from LineTCPFuzzTest to evaluate durability of metadata changes
  • tested with LineTCPSender03MultiTableMain to evaluate durability of partition squashing

When drive disappears database may become unstable, SEGFAULT or fail to stop. This matters very little because we're simulating power loss. We don't expect DB instance to keep running.

On startup database starts with no significant rows. It shows uploaded-so-far data correctly and continues WAL apply process. There were no corrupt data structures observed over multiple "power loss" events.

@bluestreak01 bluestreak01 marked this pull request as draft May 4, 2023 20:40
@bluestreak01
Copy link
Member Author

once this PR is merged we need to update this paragraph:

image

@bluestreak01 bluestreak01 added durability issue Core Related to storage, data type, etc. labels May 10, 2023
@bluestreak01 bluestreak01 marked this pull request as ready for review May 11, 2023 20:03
@bluestreak01
Copy link
Member Author

@puzpuzpuz @ideoma I think I covered all the comments. Let me know otherwise of if you find anything else

@puzpuzpuz puzpuzpuz self-requested a review May 15, 2023 14:41
@ideoma
Copy link
Collaborator

ideoma commented May 15, 2023

[PR Coverage check]

😍 pass : 290 / 357 (81.23%)

file detail

path covered line new line coverage
🔵 io/questdb/cairo/vm/NullMapWriter.java 0 1 00.00%
🔵 io/questdb/cairo/O3CopyJob.java 3 12 25.00%
🔵 io/questdb/griffin/SqlCompiler.java 2 5 40.00%
🔵 io/questdb/cairo/SymbolMapWriter.java 3 7 42.86%
🔵 io/questdb/cairo/frm/file/ContiguousFileVarFrameColumn.java 6 10 60.00%
🔵 io/questdb/cairo/wal/WalWriter.java 36 51 70.59%
🔵 io/questdb/cairo/wal/CopyWalSegmentUtils.java 10 14 71.43%
🔵 io/questdb/cairo/SymbolColumnIndexer.java 5 7 71.43%
🔵 io/questdb/std/FilesFacadeImpl.java 10 14 71.43%
🔵 io/questdb/cairo/vm/MemoryPMARImpl.java 5 7 71.43%
🔵 io/questdb/cairo/frm/file/ContiguousFileFixFrameColumn.java 9 11 81.82%
🔵 io/questdb/cairo/RebuildColumnBase.java 9 11 81.82%
🔵 io/questdb/cairo/BitmapIndexWriter.java 19 23 82.61%
🔵 io/questdb/cairo/ColumnVersionWriter.java 5 6 83.33%
🔵 io/questdb/cairo/TxWriter.java 6 7 85.71%
🔵 io/questdb/cairo/TableWriter.java 88 97 90.72%
🔵 io/questdb/cairo/IndexBuilder.java 8 8 100.00%
🔵 io/questdb/cairo/RecoverVarIndex.java 2 2 100.00%
🔵 io/questdb/cairo/wal/WalWriterEvents.java 3 3 100.00%
🔵 io/questdb/cutlass/text/CairoTextWriter.java 2 2 100.00%
🔵 io/questdb/cairo/vm/Vm.java 2 2 100.00%
🔵 io/questdb/cairo/frm/file/PartitionFrameFactory.java 3 3 100.00%
🔵 io/questdb/cairo/wal/seq/SequencerMetadata.java 1 1 100.00%
🔵 io/questdb/cairo/TableUtils.java 6 6 100.00%
🔵 io/questdb/cairo/frm/file/PartitionFrame.java 3 3 100.00%
🔵 io/questdb/cutlass/line/udp/LineUdpReceiver.java 2 2 100.00%
🔵 io/questdb/cairo/O3Basket.java 2 2 100.00%
🔵 io/questdb/cutlass/text/CsvFileIndexer.java 2 2 100.00%
🔵 io/questdb/griffin/UpdateOperatorImpl.java 3 3 100.00%
🔵 io/questdb/cairo/frm/FrameAlgebra.java 3 3 100.00%
🔵 io/questdb/cairo/wal/ApplyWal2TableJob.java 1 1 100.00%
🔵 io/questdb/cutlass/line/udp/LinuxMMLineUdpReceiver.java 2 2 100.00%
🔵 io/questdb/cutlass/line/udp/LineUdpParserImpl.java 2 2 100.00%
🔵 io/questdb/cutlass/line/udp/AbstractLineProtoUdpReceiver.java 1 1 100.00%
🔵 io/questdb/cairo/vm/MemoryCMARWImpl.java 1 1 100.00%
🔵 io/questdb/cairo/TableNameRegistryFileStore.java 2 2 100.00%
🔵 io/questdb/cairo/wal/seq/TableTransactionLog.java 2 2 100.00%
🔵 io/questdb/cairo/mig/EngineMigration.java 2 2 100.00%
🔵 io/questdb/cairo/frm/file/ContiguousFileIndexedFrameColumn.java 6 6 100.00%
🔵 io/questdb/cairo/MapWriter.java 3 3 100.00%
🔵 io/questdb/cairo/frm/file/ContiguousFileColumnPool.java 7 7 100.00%
🔵 io/questdb/cutlass/text/CopyTask.java 1 1 100.00%
🔵 io/questdb/cutlass/text/TextLoader.java 2 2 100.00%

@bluestreak01 bluestreak01 merged commit cdb840e into master May 15, 2023
20 checks passed
@bluestreak01 bluestreak01 deleted the vi_sync branch May 15, 2023 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Related to storage, data type, etc. durability issue
Projects
None yet
3 participants