You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2020/06/12 01:53:59 UTC
[activemq-artemis-native] branch master updated: ARTEMIS-2800
Improving trapping race
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis-native.git
The following commit(s) were added to refs/heads/master by this push:
new 2724921 ARTEMIS-2800 Improving trapping race
2724921 is described below
commit 272492122c4e6460de75a2451a8374c961e6eace
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Jun 11 21:30:46 2020 -0400
ARTEMIS-2800 Improving trapping race
---
.RELEASING.md.swp | Bin 0 -> 16384 bytes
.pom.xml.swp | Bin 0 -> 16384 bytes
...ache_activemq_artemis_nativo_jlibaio_LibaioContext.c | 16 +++++++++++++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/.RELEASING.md.swp b/.RELEASING.md.swp
new file mode 100644
index 0000000..40d7ef4
Binary files /dev/null and b/.RELEASING.md.swp differ
diff --git a/.pom.xml.swp b/.pom.xml.swp
new file mode 100644
index 0000000..661be31
Binary files /dev/null and b/.pom.xml.swp differ
diff --git a/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c b/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c
index d495eb4..eaecdbf 100644
--- a/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c
+++ b/src/main/c/org_apache_activemq_artemis_nativo_jlibaio_LibaioContext.c
@@ -151,6 +151,11 @@ static int ringio_get_events(io_context_t aio_ctx, long min_nr, long max,
}
if (available >= max) {
+ short retryTail = 0;
+ // we first wait for 20 iterations, to see if the tail moved
+ for (retryTail = 0; retryTail < 20 && ring->tail == tail; retryTail++) {
+ mem_barrier();
+ }
// This is to trap a possible bug from the kernel:
// https://bugzilla.redhat.com/show_bug.cgi?id=1845326
// https://issues.apache.org/jira/browse/ARTEMIS-2800
@@ -160,7 +165,10 @@ static int ringio_get_events(io_context_t aio_ctx, long min_nr, long max,
// while (ring->tail == tail) mem_barrier();
//
// however eventually we could have available==max in a legal situation what could lead to infinite loop here
- return io_getevents(aio_ctx, min_nr, max, events, timeout);
+ if (retryTail == 20) {
+ // if the tail didn't move, we will then perform a regular syscall
+ return io_getevents(aio_ctx, min_nr, max, events, timeout);
+ }
// also: I could have called io_getevents to the one at the end of this method
// but I really hate goto, so I would rather have a duplicate code here
@@ -774,6 +782,12 @@ JNIEXPORT void JNICALL Java_org_apache_activemq_artemis_nativo_jlibaio_LibaioCon
return;
}
int max = theControl->queueSize;
+ if (max > 1) {
+ // We can't maximize the queue reading
+ // as we need to check eventually for the tail moving
+ // this is to minimize the number of syscalls we perform on trapping a previous race.
+ max = max / 2;
+ }
pthread_mutex_lock(&(theControl->pollLock));
short running = 1;