From 71c032aa394fc24cf0b31fbb64f500f0b6976f30 Mon Sep 17 00:00:00 2001 From: Hyukjin Kwon Date: Fri, 9 Jan 2026 12:52:37 +0900 Subject: [PATCH] Improve error message --- cpp/src/arrow/io/interfaces.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cpp/src/arrow/io/interfaces.cc b/cpp/src/arrow/io/interfaces.cc index 75f3d71ae82..12c124ce213 100644 --- a/cpp/src/arrow/io/interfaces.cc +++ b/cpp/src/arrow/io/interfaces.cc @@ -338,10 +338,9 @@ SharedExclusiveChecker::SharedExclusiveChecker() : impl_(new Impl) {} void SharedExclusiveChecker::LockShared() { std::lock_guard lock(impl_->mutex); - // XXX The error message doesn't really describe the actual situation - // (e.g. ReadAt() called while Read() call in progress) ARROW_CHECK_EQ(impl_->n_exclusive, 0) - << "Attempted to take shared lock while locked exclusive"; + << "Cannot perform position-independent I/O (ReadAt/GetSize) while an " + "exclusive operation (Read/Seek/Tell/Peek/Close/Abort) is in progress"; ++impl_->n_shared; } @@ -354,9 +353,11 @@ void SharedExclusiveChecker::UnlockShared() { void SharedExclusiveChecker::LockExclusive() { std::lock_guard lock(impl_->mutex); ARROW_CHECK_EQ(impl_->n_shared, 0) - << "Attempted to take exclusive lock while locked shared"; + << "Cannot perform exclusive I/O operation (Read/Seek/Tell/Peek/Close/Abort) while " + "position-independent operations (ReadAt/GetSize) are in progress"; ARROW_CHECK_EQ(impl_->n_exclusive, 0) - << "Attempted to take exclusive lock while already locked exclusive"; + << "Cannot perform exclusive I/O operation (Read/Seek/Tell/Peek/Close/Abort) while " + "another exclusive operation is already in progress"; ++impl_->n_exclusive; }