hashicorp / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
28.25k stars 4.41k forks source link

Why do I have a delay in querying data by API interface? #3482

Closed lf1029698952 closed 6 years ago

lf1029698952 commented 7 years ago

I have a three node consul cluster, A, B, C, A is leader

I use the consul cluster as a service discovery for the docker container, There is a consul agent member in each docker container

When consul agent member start join CONSUL_IP, register information with Consul, and I will use api interface "consul_host:8500/health/service/web?passing&node-meta=" to query data, to determine whether member is alived。 Oddly enough, when my container start join with leader(A), and I can query the data immediately by api. but when my container start join with not leader node(B or C), I can't query the data immediately by api, “consul members” command is normal, but query the members data by api interface old data, It'll be normal in about three minutes, I can query the data normally。

Why this is the case, the data synchronization between consul nodes is delayed, or my method is wrong? And how can I query the data immediately by api. please enlighten, thanks!

consul version

Client: [0.7.5] Server: [0.7.5]

consul info

Server:

[Server `consul info` here]
agent:
        check_monitors = 0
        check_ttls = 0
        checks = 0
        services = 1
build:
        prerelease =
        revision = '21f2d5a
        version = 0.7.5
consul:
        bootstrap = true
        known_datacenters = 1
        leader = true
        leader_addr = IP:8300
        server = true
raft:
        applied_index = 856260
        commit_index = 856260
        fsm_pending = 0
        last_contact = never
        last_log_index = 856260
        last_log_term = 2
        last_snapshot_index = 852007
        last_snapshot_term = 2
        latest_configuration = [{Suffrage:Voter ID:IP:8300 Address:IP:8300} {Suffrage:Voter ID:IP:8300 Address:IP:8300} {Suffrage:Voter ID:IP:8300 Address:IP:8300}]
        latest_configuration_index = 7
        num_peers = 2
        protocol_version = 1
        protocol_version_max = 3
        protocol_version_min = 0
        snapshot_version_max = 1
        snapshot_version_min = 0
        state = Leader
        term = 2
runtime:
        arch = amd64
        cpu_count = 2
        goroutines = 160
        max_procs = 10
        os = linux
        version = go1.7.5
serf_lan:
        encrypted = true
        event_queue = 0
        event_time = 2
        failed = 0
        health_score = 0
        intent_queue = 0
        left = 15
        member_time = 713
        members = 47
        query_queue = 0
        query_time = 1
serf_wan:
        encrypted = true
        event_queue = 0
        event_time = 1
        failed = 0
        health_score = 0
        intent_queue = 0
        left = 0

Operating system and Environment details

Linux 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

slackpad commented 6 years ago

Hi @lf1029698952 sorry for the late response on this one - did you figure this out? It might help to see some log output from the servers at debug level when this is happening.

slackpad commented 6 years ago

Closing since we never heard back.