Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PLAT-10713: Support sphinx sticky session during read operations as well #9201

Merged
merged 5 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions alpha/apps/kaltura/lib/db/DbManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,25 @@ protected static function getSphinxConnIndexByLastUpdatedAt($dataSources)
}

protected static function getStickySessionKey()
{
$stickySession = self::getKsPrivilegeStickySessionKey();

if(!$stickySession)
{
$stickySession = self::STICKY_SESSION_PREFIX . infraRequestUtils::getRemoteAddress();
}

return $stickySession;
}

protected static function getKsPrivilegeStickySessionKey()
{
$ksObject = kCurrentContext::$ks_object;

if($ksObject && $ksObject->hasPrivilege(kSessionBase::PRIVILEGE_SESSION_KEY))
if($ksObject && $ksObject->hasPrivilege(kSessionBase::PRIVILEGE_SESSION_KEY))
return self::STICKY_SESSION_PREFIX . kCurrentContext::getCurrentPartnerId() . "_" . $ksObject->getPrivilegeValue(kSessionBase::PRIVILEGE_SESSION_KEY);

return self::STICKY_SESSION_PREFIX . infraRequestUtils::getRemoteAddress();
return null;
}

/**
Expand Down Expand Up @@ -284,7 +296,8 @@ public static function getSphinxConnection($read = true, $indexName = null)
KalturaLog::debug("Actual sphinx index [". self::$connIndexes[$indexName]. "] sphinx index by best lag [" . $preferredIndex. "]");
}

if (!$read)
$sphinxStickyPartnerIds = kConf::get('sphinx_sticky_partners', 'sphinx_dynamic_config', array());
if (!$read || (self::getKsPrivilegeStickySessionKey() && in_array(kCurrentContext::getCurrentPartnerId(), $sphinxStickyPartnerIds)) )
self::setSphinxConnIndexInCache($indexName);
return self::$sphinxConnection[$indexName];
}
Expand Down
20 changes: 20 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# Orion 15.18.0 #

## Support sphinx sticky connection for read operations ##
Issue Type: Task
Issue ID : PLAT-10713

### Configuration ##
* Make sure "sphinx_dynamic_config" exists in your configuration maps

* To enable the feature for specific partner ids add the following section to the map:
[sphinx_sticky_partners]
0 = XXXX
1 = YYYY
where XXXX and YYYY are the partner ids you want to enable the feature for.


#### Deployment Scripts ####
None.


# Orion 15.17.0 #

## Allow catalog item pricing view from KMC ##
Expand Down