Bugfix distributed cache
This commit is contained in:
@@ -98,8 +98,7 @@ namespace Umbraco.Core.Sync
|
||||
protected void Boot()
|
||||
{
|
||||
ReadLastSynced();
|
||||
if (_lastId < 0) // never synced before
|
||||
Initialize();
|
||||
Initialize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -107,24 +106,28 @@ namespace Umbraco.Core.Sync
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Thread safety: this is NOT thread safe. Because it is NOT meant to run multi-threaded.
|
||||
/// Callers MUST ensure thread-safety.
|
||||
/// </remarks>
|
||||
private void Initialize()
|
||||
{
|
||||
// we haven't synced - in this case we aren't going to sync the whole thing, we will assume this is a new
|
||||
// server and it will need to rebuild it's own caches, eg Lucene or the xml cache file.
|
||||
LogHelper.Warn<DatabaseServerMessenger>("No last synced Id found, this generally means this is a new server/install. The server will rebuild its caches and indexes and then adjust it's last synced id to the latest found in the database and will start maintaining cache updates based on that id");
|
||||
if (_lastId < 0) // never synced before
|
||||
{
|
||||
// we haven't synced - in this case we aren't going to sync the whole thing, we will assume this is a new
|
||||
// server and it will need to rebuild it's own caches, eg Lucene or the xml cache file.
|
||||
LogHelper.Warn<DatabaseServerMessenger>("No last synced Id found, this generally means this is a new server/install. The server will rebuild its caches and indexes and then adjust it's last synced id to the latest found in the database and will start maintaining cache updates based on that id");
|
||||
|
||||
// go get the last id in the db and store it
|
||||
// note: do it BEFORE initializing otherwise some instructions might get lost
|
||||
// when doing it before, some instructions might run twice - not an issue
|
||||
var lastId = _appContext.DatabaseContext.Database.ExecuteScalar<int>("SELECT MAX(id) FROM umbracoCacheInstruction");
|
||||
if (lastId > 0)
|
||||
SaveLastSynced(lastId);
|
||||
// go get the last id in the db and store it
|
||||
// note: do it BEFORE initializing otherwise some instructions might get lost
|
||||
// when doing it before, some instructions might run twice - not an issue
|
||||
var lastId = _appContext.DatabaseContext.Database.ExecuteScalar<int>("SELECT MAX(id) FROM umbracoCacheInstruction");
|
||||
if (lastId > 0)
|
||||
SaveLastSynced(lastId);
|
||||
|
||||
// execute initializing callbacks
|
||||
if (_options.InitializingCallbacks != null)
|
||||
foreach (var callback in _options.InitializingCallbacks)
|
||||
callback();
|
||||
// execute initializing callbacks
|
||||
if (_options.InitializingCallbacks != null)
|
||||
foreach (var callback in _options.InitializingCallbacks)
|
||||
callback();
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Umbraco.Core.Sync
|
||||
/// <summary>
|
||||
/// A registrar that stores registered server nodes in the database.
|
||||
/// </summary>
|
||||
internal sealed class DatabaseServerRegistrar : IServerRegistrar
|
||||
public sealed class DatabaseServerRegistrar : IServerRegistrar
|
||||
{
|
||||
private readonly Lazy<ServerRegistrationService> _registrationService;
|
||||
|
||||
|
||||
@@ -15,6 +15,18 @@ namespace Umbraco.Core.Sync
|
||||
// but at the moment it is exposed in CacheRefresher webservice
|
||||
// so for the time being we keep it as-is for backward compatibility reasons
|
||||
|
||||
// need the public one so it can be de-serialized
|
||||
// otherwise, should use GetInstructions(...)
|
||||
public RefreshInstruction(Guid refresherId, RefreshMethodType refreshType, Guid guidId, int intId, string jsonIds, string jsonPayload)
|
||||
{
|
||||
RefresherId = refresherId;
|
||||
RefreshType = refreshType;
|
||||
GuidId = guidId;
|
||||
IntId = intId;
|
||||
JsonIds = jsonIds;
|
||||
JsonPayload = jsonPayload;
|
||||
}
|
||||
|
||||
private RefreshInstruction(ICacheRefresher refresher, RefreshMethodType refreshType)
|
||||
{
|
||||
RefresherId = refresher.UniqueIdentifier;
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Umbraco.Core.Sync
|
||||
{
|
||||
if (refresher == null) throw new ArgumentNullException("refresher");
|
||||
|
||||
LogHelper.Debug<WebServiceServerMessenger>("Invoking refresher {0} on local server for message type {1}",
|
||||
LogHelper.Debug<ServerMessengerBase>("Invoking refresher {0} on local server for message type {1}",
|
||||
refresher.GetType,
|
||||
() => messageType);
|
||||
|
||||
@@ -200,7 +200,7 @@ namespace Umbraco.Core.Sync
|
||||
{
|
||||
if (refresher == null) throw new ArgumentNullException("refresher");
|
||||
|
||||
LogHelper.Debug<WebServiceServerMessenger>("Invoking refresher {0} on local server for message type {1}",
|
||||
LogHelper.Debug<ServerMessengerBase>("Invoking refresher {0} on local server for message type {1}",
|
||||
refresher.GetType,
|
||||
() => messageType);
|
||||
|
||||
@@ -238,7 +238,7 @@ namespace Umbraco.Core.Sync
|
||||
//{
|
||||
// if (refresher == null) throw new ArgumentNullException("refresher");
|
||||
|
||||
// LogHelper.Debug<DefaultServerMessenger>("Invoking refresher {0} on local server for message type Notify",
|
||||
// LogHelper.Debug<ServerMessengerBase>("Invoking refresher {0} on local server for message type Notify",
|
||||
// () => refresher.GetType());
|
||||
|
||||
// refresher.Notify(payload);
|
||||
|
||||
@@ -64,7 +64,11 @@ namespace Umbraco.Web
|
||||
{
|
||||
var httpContext = UmbracoContext.Current == null ? null : UmbracoContext.Current.HttpContext;
|
||||
if (httpContext == null)
|
||||
throw new NotSupportedException("Cannot execute without a valid/current UmbracoContext with an HttpContext assigned.");
|
||||
{
|
||||
if (ensure)
|
||||
throw new NotSupportedException("Cannot execute without a valid/current UmbracoContext with an HttpContext assigned.");
|
||||
return null;
|
||||
}
|
||||
|
||||
var key = typeof (BatchedDatabaseServerMessenger).Name;
|
||||
|
||||
|
||||
@@ -34,7 +34,11 @@ namespace Umbraco.Web
|
||||
{
|
||||
var httpContext = UmbracoContext.Current == null ? null : UmbracoContext.Current.HttpContext;
|
||||
if (httpContext == null)
|
||||
throw new NotSupportedException("Cannot execute without a valid/current UmbracoContext with an HttpContext assigned.");
|
||||
{
|
||||
if (ensure)
|
||||
throw new NotSupportedException("Cannot execute without a valid/current UmbracoContext with an HttpContext assigned.");
|
||||
return null;
|
||||
}
|
||||
|
||||
var key = typeof(BatchedWebServiceServerMessenger).Name;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user