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

fix(cluster) update time for consensus timeout #90

Merged
merged 1 commit into from
Apr 3, 2017
Merged
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
8 changes: 8 additions & 0 deletions lib/resty/cassandra/cluster.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local cassandra = require 'cassandra'
local cql = require 'cassandra.cql'
local ffi = require 'ffi'

local update_time = ngx.update_time
local cql_errors = cql.errors
local ffi_cast = ffi.cast
local ffi_str = ffi.string
Expand Down Expand Up @@ -588,11 +589,18 @@ local function wait_schema_consensus(self, coordinator)
elseif not peers then return nil, 'no peers in shm'
elseif #peers < 2 then return true end

update_time()

local ok, err, tdiff
local tstart = get_now()

repeat
-- disabled because this method is currently used outside of an
-- ngx_lua compatible context by production applications.
-- no fallback implemented yet.
--ngx.sleep(0.5)

update_time()
ok, err = check_schema_consensus(coordinator)
tdiff = get_now() - tstart
until ok or err or tdiff >= self.max_schema_consensus_wait
Expand Down