Skip to content

Commit

Permalink
Extended Thread logging - backport from master (#1173)
Browse files Browse the repository at this point in the history
* Extended Thread logging - Cache thread info change (#1120)

There is change in log message severity and log category. This log message is also produced if persistence 'eclipselink.cache.extended.logging' is set to true.

Signed-off-by: Radek Felcman <radek.felcman@oracle.com>
(cherry picked from commit c9272ea)
  • Loading branch information
rfelcman committed Jun 1, 2021
1 parent 4dc5d63 commit eb01b28
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
Expand Up @@ -102,7 +102,6 @@ public class LoggingLocalizationResource extends ListResourceBundle {
{ "register_new_for_persist", "PERSIST operation called on: {0}." },
{ "all_registered_clones", "All Registered Clones:" },
{ "new_objects", "New Objects:" },
{ "cache_thread_info", "Cached entity ({0}) with Id ({1}) was stored into cache by another thread (id: {2} name: {3}), than current thread (id: {4} name: {5})" },
{ "unit_of_work_thread_info", "Current unit of work in session ({0}) was created by another thread (id: {1} name: {2}), than current thread (id: {3} name: {4})" },
{ "unit_of_work_thread_info_thread_dump", "Creation thread (id: {0} name: {1}) stack trace:\n{2}\n\n" +
"Current thread (id: {3} name: {4}) stack trace:\n{5}" },
Expand Down
Expand Up @@ -108,6 +108,7 @@ public class TraceLocalizationResource extends ListResourceBundle {
{ "locked_object", "Locked Object : {0}" },
{ "depth", "Depth : {0}" },
{ "cachekey_released", "This thread is no longer holding the lock. It must not be a blocking thread."},
{ "cache_thread_info", "Cached entity ({0}) with Id ({1}) was prepared and stored into cache by another thread (id: {2} name: {3}), than current thread (id: {4} name: {5})" },
{ "deferred_locks", "Deferred lock on : {0}" },
{ "deferred_locks_released", "All deferred locks for thread \"{0}\" have been released." },
{ "acquiring_deferred_lock", "Thread \"{1}\" has acquired a deferred lock on object : {0} in order to avoid deadlock." },
Expand Down
Expand Up @@ -4048,6 +4048,7 @@ public Object registerExistingObject(Object objectToRegister, ClassDescriptor de
}
CacheKey cacheKey = null;
Object objectToRegisterId = null;
Thread currentThread = Thread.currentThread();
if (project.allowExtendedCacheLogging()) {
//Not null if objectToRegister exist in cache
Session rootSession = this.getRootSession(null).getParent() == null ? this.getRootSession(null) : this.getRootSession(null).getParent();
Expand All @@ -4058,20 +4059,13 @@ public Object registerExistingObject(Object objectToRegister, ClassDescriptor de
} else {
log(SessionLog.FINEST, SessionLog.CACHE, "cache_miss", new Object[] {objectToRegister.getClass(), objectToRegisterId});
}
}
if (project.allowExtendedThreadLogging()) {
Thread currentThread = Thread.currentThread();
if (cacheKey == null) {
cacheKey = ((org.eclipse.persistence.internal.sessions.IdentityMapAccessor) this.getRootSession(null).getParent().getIdentityMapAccessor()).getCacheKeyForObject(objectToRegister);
}
if (objectToRegisterId == null) {
objectToRegisterId = this.getId(objectToRegister);
}
if (cacheKey != null && currentThread.hashCode() != cacheKey.CREATION_THREAD_HASHCODE) {
log(SessionLog.SEVERE, SessionLog.THREAD, "cache_thread_info", new Object[]{objectToRegister.getClass(), objectToRegisterId,
log(SessionLog.FINEST, SessionLog.CACHE, "cache_thread_info", new Object[]{objectToRegister.getClass(), objectToRegisterId,
cacheKey.CREATION_THREAD_ID, cacheKey.CREATION_THREAD_NAME,
currentThread.getId(), currentThread.getName()});
}
}
if (project.allowExtendedThreadLogging()) {
if (this.CREATION_THREAD_HASHCODE != currentThread.hashCode()) {
log(SessionLog.SEVERE, SessionLog.THREAD, "unit_of_work_thread_info", new Object[]{this.getName(),
this.CREATION_THREAD_ID, this.CREATION_THREAD_NAME,
Expand Down

0 comments on commit eb01b28

Please sign in to comment.