Skip to content

Statefull Session commit performance issue when nothing changed and second level cache with query cache enabled #2115

Closed
@gokhanabatay

Description

@gokhanabatay

Hi,
I realised a perfomance issue, we are using second level cache so we need a session and transaction by default. After data read commit occours thats fine but it tries to do something with

UpdateTimestampsCache

[MethodImpl(MethodImplOptions.Synchronized)]
public virtual void Invalidate(IReadOnlyCollection<string> spaces)
{
	//TODO: to handle concurrent writes correctly, the client should pass in a Lock
	long ts = _updateTimestamps.NextTimestamp();
	//TODO: if lock.getTimestamp().equals(ts)
	if (log.IsDebugEnabled())
		log.Debug("Invalidating spaces [{0}]", StringHelper.CollectionToString(spaces));
	SetSpacesTimestamp(spaces, ts);
}

As you can see above

[MethodImpl(MethodImplOptions.Synchronized)] is a problem if spaces is empty. There are other sync. methods some of them check spaces before calling sync method some not.
I think all of them need to check spaces before calling sync method for concurrency performance issue?

Below usage checks before calling sync method.

StandartQueryCache

var upToDates = spacesToCheck.Count > 0
				? _updateTimestampsCache.AreUpToDate(spacesToCheck.ToArray(), checkedSpacesTimestamp.ToArray())
				: Array.Empty<bool>();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions