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

[Bug] Error occurs internal when context count exceeds MAX_CONTEXT_NAME_SIZE #151

Closed
sczyh30 opened this issue Sep 18, 2018 · 2 comments · Fixed by #152
Closed

[Bug] Error occurs internal when context count exceeds MAX_CONTEXT_NAME_SIZE #151

sczyh30 opened this issue Sep 18, 2018 · 2 comments · Fixed by #152
Assignees
Labels
kind/bug Category issues or prs related to bug.
Milestone

Comments

@sczyh30
Copy link
Member

sczyh30 commented Sep 18, 2018

Issue Description

Type: bug report (essential)

Describe what happened

When context count exceeds MAX_CONTEXT_NAME_SIZE (by now 2000), entries with new context will cause fatal internal errors, leading to some weird exceptions (e.g. ErrorEntryFreeException).

The NullContext does not act as expected due to bugs in ContextUtil#trueEnter.

Describe what you expected to happen

When context count exceeds MAX_CONTEXT_NAME_SIZE, entries with new context should not pass the slot chain. Entries with default context can go through the slot chain.

How to reproduce it (as minimally and precisely as possible)

A test program:

public class Test {
    public static void main(String[] args) {
        loadContexts();
        try {
            ContextUtil.enter("context-more");
            entryFor("abc");
            entryFor("bcd");
        } finally {
            ContextUtil.exit();
        }
    }

    private static void loadContexts() {
        for (int i = 0; i < 2018; i++) {
            ContextUtil.enter("a" + i);
            ContextUtil.exit();
        }
    }

    private static void entryFor(String resourceName) {
        Entry entry = null;
        try {
            entry = SphU.entry(resourceName);
        } catch (BlockException ex) {
            ex.printStackTrace();
        } finally {
            if (entry != null) {
                entry.exit();
            }
        }
    }
}

Then errors will be found in associated record.log like this:

2018-09-18 22:20:01 Sentinel unexpected exception
java.lang.NullPointerException
	at com.alibaba.csp.sentinel.slots.nodeselector.NodeSelectorSlot.entry(NodeSelectorSlot.java:166)
	at com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot.transformEntry(AbstractLinkedProcessorSlot.java:40)
	at com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot.fireEntry(AbstractLinkedProcessorSlot.java:32)
	at com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain$1.entry(DefaultProcessorSlotChain.java:31)
	at com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot.transformEntry(AbstractLinkedProcessorSlot.java:40)
	at com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain.entry(DefaultProcessorSlotChain.java:75)
	at com.alibaba.csp.sentinel.CtSph.entry(CtSph.java:142)
	at com.alibaba.csp.sentinel.CtSph.entry(CtSph.java:256)
	at com.alibaba.csp.sentinel.SphU.entry(SphU.java:86)
	at com.alibaba.csp.sentinel.demo.Test.entryFor(Test.java:69)
	at com.alibaba.csp.sentinel.demo.Test.main(Test.java:33)
2018-09-18 22:20:01 Entry exit exception
java.lang.NullPointerException
	at com.alibaba.csp.sentinel.slots.statistic.StatisticSlot.exit(StatisticSlot.java:115)
	at com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot.fireExit(AbstractLinkedProcessorSlot.java:46)
	at com.alibaba.csp.sentinel.slots.logger.LogSlot.exit(LogSlot.java:49)
	at com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot.fireExit(AbstractLinkedProcessorSlot.java:46)
	at com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot.exit(ClusterBuilderSlot.java:108)
	at com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot.fireExit(AbstractLinkedProcessorSlot.java:46)
	at com.alibaba.csp.sentinel.slots.nodeselector.NodeSelectorSlot.exit(NodeSelectorSlot.java:176)
	at com.alibaba.csp.sentinel.slotchain.AbstractLinkedProcessorSlot.fireExit(AbstractLinkedProcessorSlot.java:46)
	at com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain$1.exit(DefaultProcessorSlotChain.java:36)
	at com.alibaba.csp.sentinel.slotchain.DefaultProcessorSlotChain.exit(DefaultProcessorSlotChain.java:80)
	at com.alibaba.csp.sentinel.CtEntry.exitForContext(CtEntry.java:71)
	at com.alibaba.csp.sentinel.CtEntry.trueExit(CtEntry.java:94)
	at com.alibaba.csp.sentinel.CtEntry.exit(CtEntry.java:56)
	at com.alibaba.csp.sentinel.Entry.exit(Entry.java:74)
	at com.alibaba.csp.sentinel.demo.Test.entryFor(Test.java:74)
	at com.alibaba.csp.sentinel.demo.Test.main(Test.java:33)

Tell us your environment

  • JDK 1.8
  • Sentinel 0.2.0-SNAPSHOT (latest in master)
@sczyh30 sczyh30 added the kind/bug Category issues or prs related to bug. label Sep 18, 2018
@sczyh30 sczyh30 added this to the 0.2.0 milestone Sep 18, 2018
@sczyh30 sczyh30 self-assigned this Sep 18, 2018
@yfh0918
Copy link
Contributor

yfh0918 commented Sep 19, 2018

目前有没有规避方法

@sczyh30
Copy link
Member Author

sczyh30 commented Sep 19, 2018

We've fixed the bug and merged into master. This will be published with 0.2.0 version and a bug fix version 0.1.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants