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

Test shared mod file #14048

Draft
wants to merge 134 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
134 commits
Select commit Hold shift + click to select a range
7dc39f1
temp save
jt2594838 Oct 12, 2024
469f3b6
temp save
jt2594838 Oct 17, 2024
f115dc6
Merge branch 'master' into table_data_deletion
jt2594838 Oct 17, 2024
480b4b1
Change modification format
jt2594838 Oct 23, 2024
6104265
Merge branch 'master' into table_data_deletion
jt2594838 Oct 23, 2024
45e33a8
update tsfile version
jt2594838 Oct 23, 2024
87baed0
fix deviceId match
jt2594838 Oct 23, 2024
2ec1aa4
Merge branch 'table_data_deletion' of github.com:apache/iotdb into ta…
jt2594838 Oct 23, 2024
9bb80e3
fix identitySinOperatorTest
jt2594838 Oct 23, 2024
1dacc0b
refactor interface hierachy
jt2594838 Oct 23, 2024
acb1a47
refactor package structure
jt2594838 Oct 23, 2024
088009b
spotless
jt2594838 Oct 23, 2024
05ba9c8
support table deletion
jt2594838 Oct 25, 2024
ba59a3f
Merge branch 'table_data_deletion' of github.com:apache/iotdb into ta…
jt2594838 Oct 25, 2024
2ffd6b4
Merge branch 'master' into table_data_deletion
jt2594838 Oct 25, 2024
cb83826
fix test
jt2594838 Oct 25, 2024
2dc417f
remove v1 mod file
jt2594838 Oct 25, 2024
1a234ba
fix read empty mod
jt2594838 Oct 25, 2024
ffc3eba
add table deletion IT
jt2594838 Oct 30, 2024
655c84f
Merge branch 'master' into table_data_deletion
jt2594838 Oct 30, 2024
ba01a6f
Fix nullability check in buildTsBlock().
jt2594838 Oct 31, 2024
bec444a
fix partialPath type in TreeDeletionEntry
jt2594838 Nov 1, 2024
d64b0a0
add predicate ut
jt2594838 Nov 4, 2024
0dd0c71
allow multiple mods in a plan node
jt2594838 Nov 4, 2024
2798a66
Merge branch 'master' into table_data_deletion
jt2594838 Nov 4, 2024
bcf8ccb
implment deleteDataForDropTable & fix IT
jt2594838 Nov 5, 2024
120acb3
fix log level
jt2594838 Nov 5, 2024
d0bfa97
Merge branch 'master' into table_data_deletion
jt2594838 Nov 5, 2024
7d5c3a6
ignore one test
jt2594838 Nov 5, 2024
9b511dc
Added table IT (#13978)
Caideyipi Nov 5, 2024
4319dd7
fix RelationalDeleteDataPlan serialization
jt2594838 Nov 5, 2024
e42f159
Merge branch 'table_data_deletion' of github.com:apache/iotdb into ta…
jt2594838 Nov 5, 2024
80197cd
Merge branch 'master' into table_data_deletion
jt2594838 Nov 5, 2024
f8b1bd7
spotless
jt2594838 Nov 5, 2024
5c2230c
add license
jt2594838 Nov 5, 2024
2e1f6b1
Support more compicated deletion predicate
jt2594838 Nov 5, 2024
7d660b2
fix tests
jt2594838 Nov 5, 2024
64d6d39
update tsfile version & update tests
jt2594838 Nov 6, 2024
3f4e130
fix modEntry merge
jt2594838 Nov 6, 2024
592e595
parallel file deletion & fix ut
jt2594838 Nov 6, 2024
c511b33
add performance test
jt2594838 Nov 7, 2024
2a86245
all shared mod file framework
jt2594838 Nov 7, 2024
67359fa
fix TsFileResourceSerialization
jt2594838 Nov 7, 2024
d97bc8b
add mod file manager
jt2594838 Nov 7, 2024
f592321
fix TsFileResource deserialization
jt2594838 Nov 8, 2024
6ae9faf
fix exception handle
jt2594838 Nov 8, 2024
946b536
spotless
jt2594838 Nov 8, 2024
9ebc4b7
fulfill deletion framework
jt2594838 Nov 8, 2024
884ec96
ignore perf test
jt2594838 Nov 8, 2024
00a44b5
use buffered stream to read mods
jt2594838 Nov 8, 2024
09ba21b
fix ut
jt2594838 Nov 8, 2024
002d385
spotless
jt2594838 Nov 8, 2024
5faf169
Merge branch 'master' into table_data_deletion
jt2594838 Nov 11, 2024
76a5b3f
fix metric ut
jt2594838 Nov 11, 2024
55dd6c3
Merge branch 'table_data_deletion' into share_mod_file
jt2594838 Nov 11, 2024
182e069
spotless
jt2594838 Nov 11, 2024
aaeb322
add mod file exists marker and log condition
jt2594838 Nov 11, 2024
4645ddc
fix tests
jt2594838 Nov 12, 2024
687c606
fix tests
jt2594838 Nov 12, 2024
40b63a5
Merge branch 'table_data_deletion' into share_mod_file
jt2594838 Nov 12, 2024
6f185de
fix test
jt2594838 Nov 12, 2024
541fd73
fix recover deadlock
jt2594838 Nov 12, 2024
cc4df81
Merge branch 'table_data_deletion' into share_mod_file
jt2594838 Nov 12, 2024
41e821c
Drop column adaptation (#14073)
Caideyipi Nov 13, 2024
a87f0e7
adaptation (#14077)
Caideyipi Nov 13, 2024
17f0a7f
fix comments
jt2594838 Nov 13, 2024
d0e6e34
Merge branch 'table_data_deletion' of github.com:apache/iotdb into ta…
jt2594838 Nov 13, 2024
1fe88ff
Merge branch 'master' into table_data_deletion
jt2594838 Nov 13, 2024
67c986b
Fixed the adaptation of delete device (#14081)
Caideyipi Nov 14, 2024
bf2587f
multiple fixes
jt2594838 Nov 14, 2024
a31ff27
Merge branch 'master' into table_data_deletion
jt2594838 Nov 14, 2024
c35051d
Merge branch 'table_data_deletion' into share_mod_file
jt2594838 Nov 14, 2024
ede6028
Merge branch 'master' into share_mod_file
jt2594838 Nov 14, 2024
fcf3f8b
update maxTime in TVList after deletion
jt2594838 Nov 14, 2024
6d01f4b
Merge branch 'table_data_deletion' into share_mod_file
jt2594838 Nov 14, 2024
741d889
fix tests
jt2594838 Nov 14, 2024
ba7ab7c
spotless
jt2594838 Nov 14, 2024
3b0f1ff
fix pipe adaption
jt2594838 Nov 21, 2024
c7276b9
Merge branch 'master' into share_mod_file
jt2594838 Nov 21, 2024
4710331
fix tests
jt2594838 Nov 21, 2024
3d738ab
Fix pageModifiedStatus
jt2594838 Nov 22, 2024
4052cd6
spotless
jt2594838 Nov 22, 2024
1534ed3
fix compaction checker
jt2594838 Nov 22, 2024
8a90704
spotless
jt2594838 Nov 26, 2024
8515270
Merge branch 'master' into share_mod_file
jt2594838 Nov 26, 2024
af2cedf
Merge branch 'master' into share_mod_file
jt2594838 Dec 3, 2024
a5575b0
fix tests
jt2594838 Dec 3, 2024
b9d305b
Supplement deletion-related tests and bug fixes
jt2594838 Dec 4, 2024
4f6ead2
supplement tests
jt2594838 Dec 5, 2024
c1b703c
Add manualIT
jt2594838 Dec 5, 2024
4c80dfd
spotless and add tests
jt2594838 Dec 5, 2024
9fdda31
fix tests
jt2594838 Dec 5, 2024
c569913
fix test conflict
jt2594838 Dec 5, 2024
8322f20
exclude simpleIT
jt2594838 Dec 6, 2024
89fa541
fix test dead-loop
jt2594838 Dec 6, 2024
34d858e
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 6, 2024
b5c6404
add restart test
jt2594838 Dec 7, 2024
abf20b6
update comment
jt2594838 Dec 9, 2024
7afcee9
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 9, 2024
ada13ef
enable manualIT temporarily
jt2594838 Dec 9, 2024
4e8ab9e
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 9, 2024
9010399
modify test
jt2594838 Dec 9, 2024
4368a1a
add teardown && mod upgrade test
jt2594838 Dec 9, 2024
c66fbc1
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 9, 2024
c14ff14
update set config
jt2594838 Dec 9, 2024
652d91a
spotless
jt2594838 Dec 10, 2024
8484c64
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 10, 2024
7aef6c5
fix shared mod file recovery
jt2594838 Dec 10, 2024
5afa1b7
Merge branch 'share_mod_file' of github.com:apache/iotdb into share_m…
jt2594838 Dec 10, 2024
75582a6
separate tests
jt2594838 Dec 10, 2024
636c94e
spotless
jt2594838 Dec 10, 2024
00b66fa
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 10, 2024
1237952
fix recovery
jt2594838 Dec 10, 2024
2d8e242
Merge branch 'share_mod_file' of github.com:apache/iotdb into share_m…
jt2594838 Dec 10, 2024
e0a63a4
fix test
jt2594838 Dec 10, 2024
73ef5aa
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 10, 2024
39dd364
Merge branch 'share_mod_file' of github.com:apache/iotdb into share_m…
jt2594838 Dec 10, 2024
d6d6f2b
fix cross database deletion
jt2594838 Dec 12, 2024
c1a7b99
fix test
jt2594838 Dec 12, 2024
e740621
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 12, 2024
6e6373d
Fix losing mod during compaction
jt2594838 Dec 13, 2024
2c84281
Fix cascade mod file
jt2594838 Dec 14, 2024
a6d8161
fix InsertionCompaction
jt2594838 Dec 21, 2024
c21c509
Merge branch 'master' into table_deletion_plus
jt2594838 Dec 21, 2024
e7cb22f
fix database name comparison
jt2594838 Dec 21, 2024
482a83e
spotless
jt2594838 Dec 21, 2024
103abfe
Merge branch 'table_deletion_plus' into share_mod_file
jt2594838 Dec 24, 2024
5e1bc77
fix tests
jt2594838 Dec 25, 2024
b1ccb57
spotless
jt2594838 Dec 25, 2024
5d9c6c4
Merge branch 'master' into share_mod_file
jt2594838 Jan 2, 2025
db5be2c
Merge branch 'master' into share_mod_file
jt2594838 Jan 14, 2025
14fa120
fix tests
jt2594838 Jan 14, 2025
65172b4
Merge branch 'master' into share_mod_file
jt2594838 Jan 16, 2025
be3e043
Merge branch 'master' into share_mod_file
jt2594838 Jan 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ public void testUnsupportedValueFilter() throws SQLException {
"701: The column 'attr1' does not exist or is not a tag column", e.getMessage());
}

try {
statement.execute("DELETE FROM vehicle1 WHERE s1 = 'text'");
fail("should not reach here!");
} catch (SQLException e) {
assertEquals("701: The column 's1' does not exist or is not a tag column", e.getMessage());
}

try {
statement.execute("DELETE FROM vehicle1 WHERE attr1 = 'text'");
fail("should not reach here!");
} catch (SQLException e) {
assertEquals(
"701: The column 'attr1' does not exist or is not a tag column", e.getMessage());
}

try {
statement.execute("DELETE FROM vehicle1 WHERE s3 = 'text'");
fail("should not reach here!");
Expand Down Expand Up @@ -299,8 +314,7 @@ public void testDelAfterFlush() throws SQLException {
statement.execute("CREATE DATABASE ln3");
statement.execute("use ln3");
statement.execute(
String.format(
"CREATE TABLE vehicle3(deviceId STRING TAG, s0 INT32 FIELD, s1 INT64 FIELD, s2 FLOAT FIELD, s3 TEXT FIELD, s4 BOOLEAN FIELD)"));
"CREATE TABLE vehicle3(deviceId STRING TAG, s0 INT32 FIELD, s1 INT64 FIELD, s2 FLOAT FIELD, s3 TEXT FIELD, s4 BOOLEAN FIELD)");

statement.execute(
"INSERT INTO vehicle3(time, deviceId, s4) " + "values(1509465600000, 'd0', true)");
Expand Down Expand Up @@ -1117,8 +1131,8 @@ public void testConcurrentFlushAndRandomDeletionWithRestart()
AtomicLong deletedPointCounter = new AtomicLong(0);
ExecutorService writeDeletionThreadPool = Executors.newCachedThreadPool();
ExecutorService restartThreadPool = Executors.newCachedThreadPool();
int fileNumMax = 1000;
int pointPerFile = 1000;
int fileNumMax = 100;
int pointPerFile = 100;
int deviceNum = 4;
Future<Void> writeThread =
writeDeletionThreadPool.submit(
Expand All @@ -1145,7 +1159,7 @@ public void testConcurrentFlushAndRandomDeletionWithRestart()
deletionRange,
minIntervalToRecord,
testNum));
int restartTargetPointWritten = 100000;
int restartTargetPointWritten = 5000;
Future<Void> restartThread =
restartThreadPool.submit(
() -> restart(writtenPointCounter, restartTargetPointWritten, writeDeletionThreadPool));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,27 +121,29 @@ public void testRestart() throws SQLException {
}
}

@Ignore // data deletion
@Ignore
@Test
public void testRestartDelete() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
statement.execute("create database test");
statement.execute("use \"test\"");
statement.execute("insert into root.turbine.d1(time,s1) values(1,1)");
statement.execute("insert into root.turbine.d1(time,s1) values(2,2)");
statement.execute("insert into root.turbine.d1(time,s1) values(3,3)");
statement.execute("create table turbine (id1 string id, s1 float measurement)");
statement.execute("insert into turbine(id1, time,s1) values('d1', 1,1.0)");
statement.execute("insert into turbine(id1, time,s1) values('d1', 2,2.0)");
statement.execute("insert into turbine(id1, time,s1) values('d1', 3,3.0)");
}

TestUtils.restartDataNodes();

try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
Statement statement = connection.createStatement()) {
statement.execute("use \"test\"");
statement.execute("delete from root.turbine.d1.s1 where time<=1");
statement.execute("delete from turbine where time<=1");

ResultSet resultSet = statement.executeQuery("SELECT s1 FROM root.turbine.d1");
ResultSet resultSet = statement.executeQuery("SELECT Time,s1 FROM turbine");
assertNotNull(resultSet);
String[] exp = new String[] {"2,2.0", "3,3.0"};
String[] exp = new String[] {"1970-01-01T00:00:00.002Z,2.0", "1970-01-01T00:00:00.003Z,3.0"};
int cnt = 0;
try {
while (resultSet.next()) {
Expand All @@ -151,10 +153,10 @@ public void testRestartDelete() throws SQLException {
}

statement.execute("flush");
statement.execute("delete from root.turbine.d1.s1 where time<=2");
statement.execute("delete from turbine where time<=2");

exp = new String[] {"3,3.0"};
resultSet = statement.executeQuery("SELECT s1 FROM root.turbine.d1");
exp = new String[] {"1970-01-01T00:00:00.003Z,3.0"};
resultSet = statement.executeQuery("SELECT Time,s1 FROM turbine");
assertNotNull(resultSet);
cnt = 0;
while (resultSet.next()) {
Expand Down
Binary file added iotdb-core/datanode/101-101-0-0.tsfile.resource
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,15 @@ public class IoTDBConfig {

private CompressionType WALCompressionAlgorithm = CompressionType.LZ4;

/** the number of shared mod files in each level of each partition * */
private int levelModFileNumThreshold = 30;

/**
* when the size of a shared mod file reaches this value, new mod file will be alloacted to new
* TsFiles as long as the number of shared mod files does not exceed levelModFileNumThreshold.*
*/
private long singleModFileSizeThresholdByte = 16 * 1024L;

IoTDBConfig() {}

public int getMaxLogEntriesNumPerBatch() {
Expand Down Expand Up @@ -4334,4 +4343,20 @@ public CompressionType getWALCompressionAlgorithm() {
public void setWALCompressionAlgorithm(CompressionType WALCompressionAlgorithm) {
this.WALCompressionAlgorithm = WALCompressionAlgorithm;
}

public long getSingleModFileSizeThresholdByte() {
return singleModFileSizeThresholdByte;
}

public void setSingleModFileSizeThresholdByte(long singleModFileSizeThresholdByte) {
this.singleModFileSizeThresholdByte = singleModFileSizeThresholdByte;
}

public int getLevelModFileNumThreshold() {
return levelModFileNumThreshold;
}

public void setLevelModFileNumThreshold(int levelModFileNumThreshold) {
this.levelModFileNumThreshold = levelModFileNumThreshold;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.apache.iotdb.db.pipe.event.common.terminate.PipeTerminateEvent;
import org.apache.iotdb.db.pipe.event.common.tsfile.PipeTsFileInsertionEvent;
import org.apache.iotdb.db.queryengine.plan.planner.plan.node.write.InsertNode;
import org.apache.iotdb.db.storageengine.dataregion.modification.ModificationFile;
import org.apache.iotdb.db.storageengine.dataregion.wal.exception.WALPipeException;
import org.apache.iotdb.pipe.api.annotation.TableModel;
import org.apache.iotdb.pipe.api.annotation.TreeModel;
Expand All @@ -45,6 +46,7 @@
import org.apache.iotdb.pipe.api.exception.PipeException;
import org.apache.iotdb.rpc.TSStatusCode;

import org.apache.tsfile.utils.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -297,6 +299,50 @@ private void doTransferWrapper(
}
}

/**
* Combine the exclusive mod file and the shared mod file of the sender as the receiver's
* exclusive mod file.
*
* @return the combined mod file and its length
*/
private Pair<File, Long> doTransferModFile(
final AirGapSocket socket, final PipeTsFileInsertionEvent pipeTsFileInsertionEvent)
throws IOException {
final String pipeName = pipeTsFileInsertionEvent.getPipeName();
final long creationTime = pipeTsFileInsertionEvent.getCreationTime();
final File tsFile = pipeTsFileInsertionEvent.getTsFile();
File targetModFile = ModificationFile.getExclusiveMods(tsFile);
long lengthSent = 0;
if (pipeTsFileInsertionEvent.isWithExclusiveMod()) {
transferFilePieces(
pipeName,
creationTime,
pipeTsFileInsertionEvent.getExclusiveModFile(),
0,
targetModFile,
0,
socket,
true);
lengthSent = pipeTsFileInsertionEvent.getExclusiveModFile().length();
}

if (pipeTsFileInsertionEvent.isWithSharedMod()) {
transferFilePieces(
pipeName,
creationTime,
pipeTsFileInsertionEvent.getSharedModFile(),
pipeTsFileInsertionEvent.getSharedModFileOffset(),
targetModFile,
lengthSent,
socket,
true);
lengthSent +=
pipeTsFileInsertionEvent.getSharedModFile().length()
- pipeTsFileInsertionEvent.getSharedModFileOffset();
}
return new Pair<>(targetModFile, lengthSent);
}

private void doTransfer(
final AirGapSocket socket, final PipeTsFileInsertionEvent pipeTsFileInsertionEvent)
throws PipeException, IOException {
Expand All @@ -306,18 +352,19 @@ private void doTransfer(
final String errorMessage = String.format("Seal file %s error. Socket %s.", tsFile, socket);

// 1. Transfer file piece by piece, and mod if needed
if (pipeTsFileInsertionEvent.isWithMod() && supportModsIfIsDataNodeReceiver) {
final File modFile = pipeTsFileInsertionEvent.getModFile();
transferFilePieces(pipeName, creationTime, modFile, socket, true);
boolean modFileExists =
pipeTsFileInsertionEvent.isWithExclusiveMod() || pipeTsFileInsertionEvent.isWithSharedMod();
if (modFileExists && supportModsIfIsDataNodeReceiver) {
final Pair<File, Long> modFileAndLength = doTransferModFile(socket, pipeTsFileInsertionEvent);
transferFilePieces(pipeName, creationTime, tsFile, socket, true);
// 2. Transfer file seal signal with mod, which means the file is transferred completely
if (!send(
pipeName,
creationTime,
socket,
PipeTransferTsFileSealWithModReq.toTPipeTransferBytes(
modFile.getName(),
modFile.length(),
modFileAndLength.getLeft().getName(),
modFileAndLength.getRight(),
tsFile.getName(),
tsFile.length(),
pipeTsFileInsertionEvent.isTableModelEvent()
Expand Down
Loading
Loading