juicedata/juicefs · error · IOException

cancel token failed

Error message

cancel token failed

What it means

JuiceFSTokenRenewer.cancel throws this IOException when the filesystem for the token's service is not a JuiceFileSystem, so the token cannot be cancelled by this renewer. Mirrors the renew() check for token cancellation.

Source

Thrown at sdk/java/src/main/java/io/juicefs/kerberos/JuiceFSTokenRenewer.java:60

  @Override
  public long renew(Token<?> token, Configuration configuration) throws IOException, InterruptedException {
    String service = token.getService().toString();
    FileSystem fs = FileSystem.get(URI.create(service), configuration);
    if (fs instanceof JuiceFileSystem) {
      return ((JuiceFileSystemImpl) ((FilterFileSystem) fs).getRawFileSystem()).renewToken(token);
    }
    throw new IOException("renew token failed");
  }

  @Override
  public void cancel(Token<?> token, Configuration configuration) throws IOException, InterruptedException {
    String service = token.getService().toString();
    FileSystem fs = FileSystem.get(URI.create(service), configuration);
    if (fs instanceof JuiceFileSystem) {
      ((JuiceFileSystemImpl) ((FilterFileSystem) fs).getRawFileSystem()).cancelToken(token);
      return;
    }
    throw new IOException("cancel token failed");
  }
}

View on GitHub (pinned to c9a67b23e8)

Solutions

  1. Confirm the token's service URI points at a JuiceFS filesystem with correct fs.juicefs.impl configuration
  2. Only route JuiceFS-issued tokens to this renewer
  3. Check core-site.xml consistency on the node performing cancellation
  4. Filter tokens by filesystem type before calling cancel
Defensive patterns

Strategy: try-catch

Validate before calling

FileSystem fs = FileSystem.get(URI.create(token.getService().toString()), conf);
boolean canCancel = fs instanceof JuiceFileSystem;

Type guard

boolean isCancellableJuiceFsToken(Token<?> t, Configuration c) {
  try { return FileSystem.get(URI.create(t.getService().toString()), c) instanceof JuiceFileSystem; }
  catch (Exception e) { return false; }
}

Try / catch

try {
  renewer.cancel(token, conf);
} catch (IOException e) {
  if ("cancel token failed".equals(e.getMessage())) {
    LOG.warn("Skipping cancel for non-JuiceFS token", e);
  } else throw e;
}

Prevention

When it happens

Trigger: Token cancellation (testToken path) with a token whose service URI resolves to a non-JuiceFS FileSystem, or where the returned instance is not a FilterFileSystem wrapping JuiceFileSystemImpl.

Common situations: Job cleanup cancelling delegated tokens from multiple filesystems; mismatched fs.juicefs.impl config between client and job submission node; stale tokens from a filesystem no longer configured.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of juicedata/juicefs@c9a67b23e8 (2026-09-06). Data as JSON: /api/errors/61a001f442533864. Report an issue: GitHub.