Skip to content

Commit 9ddab97

Browse files
authored
fix(eBPF): Flush symbol cache after replay to avoid unsent data (#11743)
During replay, keep symbols cached in g_symbol_buffer. After replay_callbacks(jvmti) completes, immediately flush g_cached_bytes under g_df_lock protection. Once flush is done, set replay_finish = true. df_send_symbol() now only sends the current symbol when replay_finish == true, and no longer flushes replay cache automatically. This prevents cached data from being left unsent if no new symbol events occur after replay completes.
1 parent 25c9d5a commit 9ddab97

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

agent/src/ebpf/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ OBJS := user/elf.o \
102102
user/profile/java/collect_symbol_files.o
103103

104104
JAVA_TOOL := deepflow-jattach
105-
JAVA_AGENT_VERSION := 3
105+
JAVA_AGENT_VERSION := 4
106106
JAVA_AGENT_GNU_SO := df_java_agent_v$(JAVA_AGENT_VERSION).so
107107
JAVA_AGENT_MUSL_SO := df_java_agent_musl_v$(JAVA_AGENT_VERSION).so
108108
JAVA_AGENT_SO := $(JAVA_AGENT_GNU_SO) $(JAVA_AGENT_MUSL_SO)

agent/src/ebpf/user/profile/java/symbol_collect_agent.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,6 @@ void df_send_symbol(enum event_type type, const void *code_addr,
323323
send_bytes = meta->len + sizeof(*meta);
324324
pthread_mutex_lock(&g_df_lock);
325325
if (replay_finish) {
326-
if (g_cached_bytes > 0) {
327-
send_msg(perf_map_socket_fd, g_symbol_buffer,
328-
g_cached_bytes);
329-
g_cached_bytes = 0;
330-
}
331326
send_msg(perf_map_socket_fd, symbol_str, send_bytes);
332327
} else {
333328
int buff_remain_bytes =
@@ -566,7 +561,16 @@ Agent_OnAttach(JavaVM * vm, char *options, void *reserved)
566561
if (g_jvmti == NULL)
567562
g_jvmti = jvmti;
568563
_(replay_callbacks(jvmti));
564+
pthread_mutex_lock(&g_df_lock);
565+
if (g_cached_bytes > 0) {
566+
if (perf_map_socket_fd >= 0) {
567+
send_msg(perf_map_socket_fd, g_symbol_buffer,
568+
g_cached_bytes);
569+
}
570+
g_cached_bytes = 0;
571+
}
569572
replay_finish = true;
573+
pthread_mutex_unlock(&g_df_lock);
570574
df_log
571575
("- JVMTI symbolization agent startup sequence complete. Replay count %d\n",
572576
replay_count);

0 commit comments

Comments
 (0)