Skip to content

Commit 0c8bf77

Browse files
IGNITE-27313 SQL: Add information about query initiator id to log
1 parent 338c201 commit 0c8bf77

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

modules/calcite/src/test/java/org/apache/ignite/internal/processors/query/calcite/integration/SqlDiagnosticIntegrationTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,11 +1028,14 @@ public void testSqlFieldsQueryWithInitiatorId() throws Exception {
10281028
}, 3_000));
10291029
}
10301030

1031-
LogListener logLsnr = LogListener.matches(LONG_QUERY_FINISHED_MSG).andMatches("initiatorId=testId2").build();
1031+
String initiatorId = "testId2";
1032+
1033+
LogListener logLsnr = LogListener.matches(LONG_QUERY_FINISHED_MSG)
1034+
.andMatches("initiatorId=" + initiatorId).build();
10321035

10331036
log.registerListener(logLsnr);
10341037

1035-
cache.query(new SqlFieldsQuery("SELECT sleep(?)").setArgs(LONG_QRY_TIMEOUT).setQueryInitiatorId("testId2"))
1038+
cache.query(new SqlFieldsQuery("SELECT sleep(?)").setArgs(LONG_QRY_TIMEOUT).setQueryInitiatorId(initiatorId))
10361039
.getAll();
10371040

10381041
assertTrue(logLsnr.check(1000));

modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/H2DmlInfo.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ public class H2DmlInfo implements TrackableQuery {
3838
/** Schema name. */
3939
private final String schema;
4040

41+
/** Query initiator id. */
42+
private final String initiatorId;
43+
4144
/** Dml command. */
4245
private final String sql;
4346

@@ -48,11 +51,12 @@ public class H2DmlInfo implements TrackableQuery {
4851
* @param schema Schema name.
4952
* @param sql Dml command.
5053
*/
51-
public H2DmlInfo(long beginTs, long qryId, UUID initNodeId, String schema, String sql) {
54+
public H2DmlInfo(long beginTs, long qryId, UUID initNodeId, String schema, String initiatorId, String sql) {
5255
this.beginTs = beginTs;
5356
this.qryId = qryId;
5457
this.initNodeId = initNodeId;
5558
this.schema = schema;
59+
this.initiatorId = initiatorId;
5660
this.sql = sql;
5761
}
5862

@@ -76,6 +80,7 @@ public H2DmlInfo(long beginTs, long qryId, UUID initNodeId, String schema, Strin
7680
msgSb.append(", duration=").append(time()).append("ms")
7781
.append(", type=DML")
7882
.append(", schema=").append(schema)
83+
.append(", initiatorId=").append(initiatorId)
7984
.append(", sql='").append(sql).append("']");
8085

8186
return msgSb.toString();

modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,6 +1064,7 @@ private List<? extends FieldsQueryCursor<List<?>>> executeDml(
10641064
qryId,
10651065
ctx.localNodeId(),
10661066
qryDesc.schemaName(),
1067+
qryDesc.queryInitiatorId(),
10671068
qryDesc.sql()
10681069
);
10691070

modules/indexing/src/test/java/org/apache/ignite/internal/processors/query/LongRunningQueryTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ public void testEmptyHeavyQueriesTrackerWithMultipleCancelledQueries() {
525525
*/
526526
@Test
527527
@MultiNodeTest
528-
public void testQueryInitiatorId() throws Exception {
528+
public void testQueryInitiatorId() {
529529
ListeningTestLogger testLog = testLog();
530530

531531
checkInitiatorId(testLog, "LOCAL", "SELECT sleep_func(?, 0)", LONG_QUERY_WARNING_TIMEOUT);
@@ -535,13 +535,17 @@ public void testQueryInitiatorId() throws Exception {
535535

536536
checkInitiatorId(testLog, "REDUCE", "SELECT sleep_func(?, sum(val)) FROM test WHERE id + 1 = 1",
537537
LONG_QUERY_WARNING_TIMEOUT);
538+
539+
checkInitiatorId(testLog, "DML", "UPDATE test SET val = sleep_func(?, val) WHERE id = 0",
540+
LONG_QUERY_WARNING_TIMEOUT);
538541
}
539542

540543
/** */
541544
private void checkInitiatorId(ListeningTestLogger log, String type, String sql, Object... args) {
542545
String initiatorId = UUID.randomUUID().toString();
543546

544-
LogListener lsnr = LogListener.matches(LONG_QUERY_FINISHED_MSG).andMatches(type).andMatches(initiatorId).build();
547+
LogListener lsnr = LogListener.matches(LONG_QUERY_FINISHED_MSG).andMatches("type=" + type)
548+
.andMatches("initiatorId=" + initiatorId).build();
545549

546550
log.registerListener(lsnr);
547551

0 commit comments

Comments
 (0)