Skip to content

Commit 51e06a2

Browse files
ideomaclaude
andcommitted
Address review comments
- Normalize txnMinTimestamp/txnMaxTimestamp to Numbers.LONG_NULL for empty commits before emitting telemetry (avoids bogus Long.MAX_VALUE/-1 values) - Sort WAL_TXN_COMMITTED constant alphabetically in TelemetryEvent - Sort telemetryWal and walTelemetryEnabled fields alphabetically in WalWriter - Replace assertSql with assertQueryNoLeakCheck in TelemetryTest Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent ae9a58f commit 51e06a2

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

core/src/main/java/io/questdb/TelemetryEvent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public final class TelemetryEvent {
6161
public static final short VIEW_DROP = 211;
6262
public static final short WAL_APPLY_RESUME = 108;
6363
public static final short WAL_APPLY_SUSPEND = 107;
64-
public static final short WAL_TXN_COMMITTED = 109;
6564
public static final short WAL_TXN_APPLY_START = 103;
65+
public static final short WAL_TXN_COMMITTED = 109;
6666
public static final short WAL_TXN_DATA_APPLIED = 105;
6767
public static final short WAL_TXN_SQL_APPLIED = 106;
6868
public static final short WAL_TXN_STRUCTURE_CHANGE_APPLIED = 104;

core/src/main/java/io/questdb/cairo/wal/WalWriter.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public class WalWriter extends WalWriterBase implements TableWriterAPI {
123123
private final MetadataService metaWriterSvc = new MetadataWriterService();
124124
private final WalWriterMetadata metadata;
125125
private final Metrics metrics;
126-
private final Telemetry<TelemetryWalTask> telemetryWal;
127126
private final ObjList<Runnable> nullSetters;
128127
private final RecentWriteTracker recentWriteTracker;
129128
private final RowImpl row = new RowImpl();
@@ -132,11 +131,12 @@ public class WalWriter extends WalWriterBase implements TableWriterAPI {
132131
private final BoolList symbolMapNullFlagsChanged = new BoolList();
133132
private final ObjList<SymbolMapReader> symbolMapReaders = new ObjList<>();
134133
private final ObjList<DirectCharSequenceIntHashMap> symbolMaps = new ObjList<>();
135-
private final boolean walTelemetryEnabled;
134+
private final Telemetry<TelemetryWalTask> telemetryWal;
136135
private final TimestampDriver timestampDriver;
137136
private final int timestampIndex;
138137
private final ObjList<Utf8StringIntHashMap> utf8SymbolMaps = new ObjList<>();
139138
private final Uuid uuid = new Uuid();
139+
private final boolean walTelemetryEnabled;
140140
private long avgRecordSize;
141141
private SegmentColumnRollSink columnConversionSink;
142142
private int columnCount;
@@ -891,6 +891,12 @@ private void commit0(
891891
syncIfRequired();
892892
final long seqTxn = getSequencerTxn();
893893
if (walTelemetryEnabled) {
894+
final long minTs = (txnRowCount == 0 || txnMinTimestamp == Long.MAX_VALUE)
895+
? Numbers.LONG_NULL
896+
: txnMinTimestamp;
897+
final long maxTs = (txnRowCount == 0 || txnMaxTimestamp < 0)
898+
? Numbers.LONG_NULL
899+
: txnMaxTimestamp;
894900
TelemetryWalTask.store(
895901
telemetryWal,
896902
TelemetryEvent.WAL_TXN_COMMITTED,
@@ -900,8 +906,8 @@ private void commit0(
900906
txnRowCount,
901907
txnRowCount,
902908
0L,
903-
txnMinTimestamp,
904-
txnMaxTimestamp
909+
minTs,
910+
maxTs
905911
);
906912
}
907913
final boolean hasReplaceRange = replaceRangeHiTs > replaceRangeLowTs;

core/src/test/java/io/questdb/test/TelemetryTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,9 @@ public void testTelemetryWalTableUpgrade() throws Exception {
411411
"\tlatency FLOAT\n";
412412
String end = " BYPASS WAL;\n";
413413

414-
assertSql(header + ") timestamp(created) PARTITION BY MONTH" + end, showCreateTable);
414+
assertQueryNoLeakCheck(header + ") timestamp(created) PARTITION BY MONTH" + end, showCreateTable);
415415
try (TelemetryJob ignore = new TelemetryJob(engine)) {
416-
assertSql(header.replace("\tlatency FLOAT\n", "\tlatency FLOAT,\n") +
416+
assertQueryNoLeakCheck(header.replace("\tlatency FLOAT\n", "\tlatency FLOAT,\n") +
417417
"\tminTimestamp TIMESTAMP,\n" +
418418
"\tmaxTimestamp TIMESTAMP\n" +
419419
") timestamp(created) PARTITION BY DAY TTL 1 WEEK" + end, showCreateTable);

0 commit comments

Comments
 (0)